diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index b50aaf824..41d551f2b 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -94,7 +94,7 @@ module.exports = Self => { const models = Self.app.models; const storageConnector = Self.app.dataSources.storage.connector; const myUserId = ctx.req.accessToken.userId; - const myWorker = await models.Worker.findOne({where: {userFk: myUserId}}); + const myWorker = await models.Worker.findOne({where: {userFk: myUserId}}, myOptions); const args = ctx.args; const newDms = await Self.create({ diff --git a/back/methods/message/send.js b/back/methods/message/send.js index f7b7ad76e..c8849774b 100644 --- a/back/methods/message/send.js +++ b/back/methods/message/send.js @@ -29,8 +29,8 @@ module.exports = Self => { const accessToken = ctx.options && ctx.options.accessToken || ctx.req && ctx.req.accessToken; const userId = accessToken.userId; const models = Self.app.models; - const sender = await models.Account.findById(userId, options); - const recipient = await models.Account.findById(data.recipientFk, options); + const sender = await models.Account.findById(userId, null, options); + const recipient = await models.Account.findById(data.recipientFk, null, options); await Self.create({ sender: sender.name, diff --git a/db/changes/10091-iberflora/00-route.sql b/db/changes/10091-iberflora/00-route.sql new file mode 100644 index 000000000..5d8b8de62 --- /dev/null +++ b/db/changes/10091-iberflora/00-route.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn`.`route` +ADD COLUMN `zoneFk` INT NULL AFTER `description`, +ADD INDEX `fk_route_1_idx` (`zoneFk` ASC); +; +ALTER TABLE `vn`.`route` +ADD CONSTRAINT `fk_route_1` + FOREIGN KEY (`zoneFk`) + REFERENCES `vn`.`zone` (`id`) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/db/changes/10100-AllSaints/00-ACL.sql b/db/changes/10100-AllSaints/00-ACL.sql new file mode 100644 index 000000000..ea1ba706b --- /dev/null +++ b/db/changes/10100-AllSaints/00-ACL.sql @@ -0,0 +1 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('UserPhone', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10100-AllSaints/00-userLog.sql b/db/changes/10100-AllSaints/00-userLog.sql new file mode 100644 index 000000000..2e541eaf4 --- /dev/null +++ b/db/changes/10100-AllSaints/00-userLog.sql @@ -0,0 +1,18 @@ +CREATE TABLE `vn`.`userLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `userLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `userLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/db/changes/10100-AllSaints/00-userPhoneType.sql b/db/changes/10100-AllSaints/00-userPhoneType.sql new file mode 100644 index 000000000..6bfedcc71 --- /dev/null +++ b/db/changes/10100-AllSaints/00-userPhoneType.sql @@ -0,0 +1,9 @@ +CREATE TABLE `vn`.`userPhoneType` ( + `code` VARCHAR(45) NOT NULL, + `description` VARCHAR(255) NULL, + PRIMARY KEY (`code`)); + + + +INSERT INTO `vn`.`userPhoneType` (`code`, `description`) VALUES ('businessPhone', 'Telefono de empresa del usuario'); +INSERT INTO `vn`.`userPhoneType` (`code`, `description`) VALUES ('personalPhone', 'Telefono personal del usuario'); diff --git a/db/changes/10100-AllSaints/01-userPhone.sql b/db/changes/10100-AllSaints/01-userPhone.sql new file mode 100644 index 000000000..488bbb112 --- /dev/null +++ b/db/changes/10100-AllSaints/01-userPhone.sql @@ -0,0 +1,63 @@ +CREATE TABLE `vn`.`userPhone` ( + `id` INT NOT NULL AUTO_INCREMENT, + `userFk` INT(10) UNSIGNED NOT NULL, + `typeFk` VARCHAR(45) NOT NULL, + `phone` INT(15) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `UserFK_Phone` (`userFk` ASC, `phone` ASC)); + + +ALTER TABLE `vn`.`userPhone` +ADD CONSTRAINT `fgnTypeFk` + FOREIGN KEY (typeFk) + REFERENCES `vn`.`userPhoneType` (code) + ON DELETE RESTRICT + ON UPDATE CASCADE; + +ALTER TABLE `vn`.`userPhone` +ADD CONSTRAINT `fgnUserFk` + FOREIGN KEY (userFk) + REFERENCES `account`.`user` (id) + ON DELETE CASCADE + ON UPDATE CASCADE; + +insert into vn.userPhone(userFk,typeFk,phone) + select id,'PersonalPhone', phone + from vn.client + where phone is not null; + + +insert into vn.userPhone(userFk,typeFk,phone) + select id,'businessPhone', phone + from vn.worker + where phone is not null AND phone > ''; + +insert into vn.userPhone(userFk,typeFk,phone) + SELECT + `w`.`userFk`, + 'businessPhone', + `m`.`value` AS `mediaValue` + FROM + (((((`postgresql`.`person` `p` + JOIN `postgresql`.`profile` `po` ON ((`po`.`person_id` = `p`.`person_id`))) + JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`))) + JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`))) + JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`))) + JOIN `vn`.`worker` `w` ON ((`w`.`id` = `p`.`id_trabajador`))) + WHERE + (`mt`.`name` = 'movil empresa'); + +insert into vn.userPhone(userFk,typeFk,phone) + SELECT + `w`.`userFk`, + 'personalPhone', + `m`.`value` AS `mediaValue` + FROM + (((((`postgresql`.`person` `p` + JOIN `postgresql`.`profile` `po` ON ((`po`.`person_id` = `p`.`person_id`))) + JOIN `postgresql`.`profile_media` `pom` ON ((`pom`.`profile_id` = `po`.`profile_id`))) + JOIN `postgresql`.`media` `m` ON ((`m`.`media_id` = `pom`.`media_id`))) + JOIN `postgresql`.`media_type` `mt` ON ((`mt`.`media_type_id` = `m`.`media_type_id`))) + JOIN `vn`.`worker` `w` ON ((`w`.`id` = `p`.`id_trabajador`))) + WHERE + (`mt`.`name` = 'movil personal') \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 6a2c13f67..d963b5662 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10070',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10080',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -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-16 13:23:24 +-- Dump completed on 2019-10-14 13:22:52 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),(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); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(49,36),(61,36),(17,37),(38,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(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); +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,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,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-16 13:23:24 +-- Dump completed on 2019-10-14 13:22:52 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -119,7 +119,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','*','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','WRITE','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(193,'Zone','editPrices','WRITE','ALLOW','ROLE','deliveryBoss'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','*','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','WRITE','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(193,'Zone','editPrices','WRITE','ALLOW','ROLE','deliveryBoss'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -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-16 13:23:24 +-- Dump completed on 2019-10-14 13:22:52 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,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); +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),(85,'2019-09-18 22:00:00','4771000000','CEE',6,5,1); /*!40000 ALTER TABLE `bookingPlanner` ENABLE KEYS */; UNLOCK TABLES; @@ -227,7 +227,7 @@ 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),(106,'Calibre',1,1,NULL,NULL,NULL),(107,'Dulzura',1,1,NULL,'bx',NULL),(108,'Piezas',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),(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,1,NULL,'g',NULL),(23,'Tallos',1,1,NULL,NULL,NULL),(24,'Estado',1,0,NULL,NULL,NULL),(25,'Color principal',0,0,'ink',NULL,NULL),(26,'Color secundario',0,0,'ink',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',1,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,1,NULL,'cm',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',1,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,1,NULL,'cm',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),(109,'Altura con patas',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -270,6 +270,26 @@ LOCK TABLES `claimResult` WRITE; 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; + +-- +-- Dumping data for table `ticketUpdateAction` +-- + +LOCK TABLES `ticketUpdateAction` WRITE; +/*!40000 ALTER TABLE `ticketUpdateAction` DISABLE KEYS */; +INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket'),(3,'Convertir en maná'); +/*!40000 ALTER TABLE `ticketUpdateAction` 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,1,0,0),(2,'Libre',1,0,'FREE',NULL,2,0,0),(3,'OK',3,0,'OK',3,28,1,0),(4,'Impreso',4,1,'PRINTED',2,29,1,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1),(9,'Encajando',9,1,'PACKING',NULL,9,0,1),(10,'Encajado',10,2,'PACKED',NULL,10,0,1),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0),(24,'Encadenado',3,0,'CHAINED',4,24,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0),(28,'zz Previa',3,1,'OK PREVIOUS',3,28,1,0),(29,'zzmpreso Previa',4,1,'PRINTED PREVIOUS',2,29,1,0); +/*!40000 ALTER TABLE `state` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -280,7 +300,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:25 +-- Dump completed on 2019-10-14 13:22:53 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -309,26 +329,6 @@ INSERT INTO `accion_dits` VALUES (0,'Abono del ticket'),(104,'Abre a pesar del a /*!40000 ALTER TABLE `accion_dits` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `bionic_updating_options` --- - -LOCK TABLES `bionic_updating_options` WRITE; -/*!40000 ALTER TABLE `bionic_updating_options` DISABLE KEYS */; -INSERT INTO `bionic_updating_options` VALUES (1,'Cambiar los precios en el ticket'),(3,'Convertir en maná'); -/*!40000 ALTER TABLE `bionic_updating_options` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `businessReasonEnd` --- - -LOCK TABLES `businessReasonEnd` WRITE; -/*!40000 ALTER TABLE `businessReasonEnd` DISABLE KEYS */; -INSERT INTO `businessReasonEnd` VALUES (1,'Baja voluntaria'),(2,'No supera PP empresa'),(3,'Despido'),(4,'Fin de contrato'),(5,'Baja por fijo discontinuo'),(6,'Modificación de jornada'),(7,'No se incorpora'),(8,'Fin Obra'),(9,'Ninguno'),(10,'Cambio departamento'),(11,'Modificación de contrato'),(12,'Cambio categoria'),(13,'Sanción/suspensión'),(14,'Pago directo Mutua'),(15,'Renovación'),(16,'No supera PP trabajador'),(17,'Cambio de salario'),(18,'Jubilación'),(19,'Cambio horario'); -/*!40000 ALTER TABLE `businessReasonEnd` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `container` -- @@ -368,26 +368,6 @@ LOCK TABLES `Grupos` WRITE; INSERT INTO `Grupos` VALUES (1,'administrative','Contabilidad',5),(2,'administrator','Administradores',5),(3,'advancedUser','Usuarios avanzados',5),(4,'developer','Informaticos',4),(5,'clientManagement','Gestion Clientes',4),(6,'salesPerson','Comerciales',4),(7,'wages','Salarios',5),(8,'salesPersonDirector','Dir Comercial',4),(9,'advancedSalesPerson','Comercial avanzado',4),(10,'','Compradores',4),(11,'','Control descuentos',4),(12,'takeOrder','Sacador',1),(13,'packer','Encajador',2),(14,' deliveryMan','Repartidor',3),(15,'','No Recalcular',4),(17,'other','Otros',4),(18,'','Operaciones',4),(19,'','Visa',5),(20,'market','Mercado',4),(21,'','Gerencia',5),(22,'','ComercialExclusivo',4),(23,'','Responsables Entradas',5),(24,'teamBoss','Jefes de equipo',4),(25,'','Responsables Encajado',0),(26,'confection','Confeccion',0),(27,'claims','Reclamaciones',0),(28,'','Ranking Carteras Limpias',0),(29,'','No bionicos',0),(30,'','Tirar a Faltas',0),(31,'','Greuges',0),(32,'','Responsables Agencias',0),(33,'','Entradas EXPRESS',0),(34,'','Sustituciones',0),(35,'router','Enrutador',4); /*!40000 ALTER TABLE `Grupos` ENABLE KEYS */; UNLOCK TABLES; - --- --- Dumping data for table `iva_group_codigo` --- - -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),(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 `state` --- - -LOCK TABLES `state` WRITE; -/*!40000 ALTER TABLE `state` DISABLE KEYS */; -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 */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -398,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:25 +-- Dump completed on 2019-10-14 13:22:53 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -446,7 +426,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:25 +-- Dump completed on 2019-10-14 13:22:53 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -484,7 +464,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:26 +-- Dump completed on 2019-10-14 13:22:53 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -509,7 +489,7 @@ USE `hedera`; LOCK TABLES `imageCollection` WRITE; /*!40000 ALTER TABLE `imageCollection` DISABLE KEYS */; -INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item','image','vn2008','Articles','Foto'),(4,'link','Enlace',200,200,'Link','image','hedera','link','image'),(5,'news','Noticias',800,1200,'New','image','hedera','news','image'); +INSERT INTO `imageCollection` VALUES (1,'catalog','Artículo',3840,2160,'Item','image','vn','item','image'),(4,'link','Enlace',200,200,'Link','image','hedera','link','image'),(5,'news','Noticias',800,1200,'New','image','hedera','news','image'); /*!40000 ALTER TABLE `imageCollection` ENABLE KEYS */; UNLOCK TABLES; @@ -552,7 +532,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:26 +-- Dump completed on 2019-10-14 13:22:53 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -577,7 +557,7 @@ USE `postgresql`; LOCK TABLES `calendar_labour_type` WRITE; /*!40000 ALTER TABLE `calendar_labour_type` DISABLE KEYS */; -INSERT INTO `calendar_labour_type` VALUES (1,'Horario general','00:20:00',40),(2,'Horario 35h/semana','00:20:00',35),(3,'Horario 20h/semana','00:00:00',20),(4,'Festivo y Fin de semana','00:00:00',0),(5,'Horario 30h/semana','00:20:00',30),(6,'Horario 25h/semana','00:20:00',25),(7,'Vacaciones trabajadas','00:00:00',0),(8,'Vacaciones','00:00:00',0),(9,'Horario 26h/semana','00:20:00',26),(10,'Horario 28h/semana','00:20:00',28),(11,'Horario 8h/semana','00:00:00',8),(12,'Horario 16h/semana','00:00:00',16),(13,'Horario 32h/semana','00:20:00',32),(14,'Horario 24h/semana','00:20:00',24),(15,'Horario 10h/semana','00:00:00',10),(16,'Horario 27,5h/semana','00:20:00',28),(17,'Horario 13,5h/semana','00:20:00',14),(18,'Horario 31h/semana',NULL,31),(19,'Horario 21,5h/semana',NULL,22),(20,'Horario 34h/semana',NULL,34),(21,'Horario 17h/semana',NULL,17),(22,'Horario 18h/semana',NULL,18),(23,'Horario 37,5 h/semana',NULL,38),(24,'Horario 29 h/semana',NULL,29),(25,'Horario 12h/semana',NULL,12),(26,'Horario 10h/semana',NULL,10),(27,'Horario 15h/semana',NULL,15),(28,'Horario 9h/semana',NULL,9); +INSERT INTO `calendar_labour_type` VALUES (1,'Horario general','00:20:00',40),(2,'Horario 35h/semana','00:20:00',35),(3,'Horario 20h/semana','00:00:00',20),(4,'Festivo y Fin de semana','00:00:00',0),(5,'Horario 30h/semana','00:20:00',30),(6,'Horario 25h/semana','00:20:00',25),(7,'Vacaciones trabajadas','00:00:00',0),(8,'Vacaciones','00:00:00',0),(9,'Horario 26h/semana','00:20:00',26),(10,'Horario 28h/semana','00:20:00',28),(11,'Horario 8h/semana','00:00:00',8),(12,'Horario 16h/semana','00:00:00',16),(13,'Horario 32h/semana','00:20:00',32),(14,'Horario 24h/semana','00:20:00',24),(15,'Horario 10h/semana','00:00:00',10),(16,'Horario 27,5h/semana','00:20:00',28),(17,'Horario 13,5h/semana','00:20:00',14),(18,'Horario 31h/semana',NULL,31),(19,'Horario 21,5h/semana',NULL,22),(20,'Horario 34h/semana',NULL,34),(21,'Horario 17h/semana',NULL,17),(22,'Horario 18h/semana',NULL,18),(23,'Horario 37,5 h/semana',NULL,38),(24,'Horario 29 h/semana',NULL,29),(25,'Horario 12h/semana',NULL,12),(26,'Horario 10h/semana',NULL,10),(27,'Horario 15h/semana',NULL,15),(28,'Horario 9h/semana',NULL,9),(29,'Horario 23h/semana',NULL,23),(30,'Horario 21h/semana',NULL,21),(31,'Horario 39h/semana',NULL,39); /*!40000 ALTER TABLE `calendar_labour_type` ENABLE KEYS */; UNLOCK TABLES; @@ -627,7 +607,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -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); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1023,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20007,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2851,5),(6,'Vilassar',88,88031,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 */; @@ -640,4 +620,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:23:26 +-- Dump completed on 2019-10-14 13:22:54 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f701c4121..2624f1768 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -65,6 +65,11 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasA (4, 'Warehouse Four', 1, 1, 1, 1, 0), (5, 'Warehouse Five', 1, 1, 1, 1, 0); +INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) + VALUES + (1, 'First sector', 1, 1, 'FIRST', 999, 999), + (2, 'Second sector', 2, 0, 'SECOND', 100, 150); + INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) VALUES (1, 'Main Warehouse'); @@ -194,8 +199,8 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city (108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), (109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), (110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1), - (200, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1), - (400, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1); + (111, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1), + (112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1); INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `phone`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 623111111, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1 @@ -221,8 +226,8 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 1), (9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 1), (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 1), - (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 1), - (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 1), + (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 111, 10, NULL, NULL, 0, 1), + (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 112, 10, NULL, NULL, 0, 1), (101, 'address 01', 'Somewhere in Thailand', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), (102, 'address 02', 'Somewhere in Poland', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0), (103, 'address 03', 'Somewhere in Japan', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0), @@ -252,9 +257,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (127, 'address 27', 'Your pocket', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0, 0), (128, 'address 28', 'Cerebro', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 0), (129, 'address 29', 'Luke Cages Bar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 0), - (130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0, 0), - (131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 0), - (132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 0); + (130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0, 0); INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`) SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1 @@ -471,7 +474,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (14, 1, 2, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 104, 'Malibu Point', 4, NULL, 0, 9, CURDATE()), (15, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 105, 'Plastic Cell', 125, NULL, 0, 3, CURDATE()), (16, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, 3, CURDATE()), - (17, 1, 7, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, 3, CURDATE()), + (17, 1, 7, 2, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 106, 'Many Places', 126, NULL, 0, 3, CURDATE()), (18, 1, 4, 4, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 108, 'Cerebro', 128, NULL, 0, 12, CURDATE()), (19, 1, 5, 5, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL + 1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 1, 13, CURDATE()), (20, 1, 5, 5, 3, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 109, 'Somewhere in Thailand', 129, NULL, 0, 13, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 16dc74449..cc01e461f 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=16332 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=16659 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=7691296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9887018 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=82661609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=95145162 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2166,7 +2166,7 @@ CREATE TABLE `claims_ratio` ( `recobro` decimal(5,2) DEFAULT NULL, `inflacion` decimal(5,2) NOT NULL DEFAULT '1.00', PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `claims_ratio_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `claims_ratio_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2211,8 +2211,8 @@ CREATE TABLE `customer_risk` ( `amount` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`customer_id`,`company_id`), KEY `company_id` (`company_id`), - CONSTRAINT `customer_risk_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `customer_risk_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `vn2008`.`empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `customer_risk_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `customer_risk_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Saldo de apertura < 2015-01-01'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2260,7 +2260,7 @@ DROP TABLE IF EXISTS `f_tvc`; CREATE TABLE `f_tvc` ( `Id_Ticket` int(11) NOT NULL, PRIMARY KEY (`Id_Ticket`), - CONSTRAINT `id_ticket_to_comisionantes` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `id_ticket_to_comisionantes` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacenamos la lista de tickets para agilizar la consulta. Corresponde a los clientes REAL y en los almacenes COMISIONANTES'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2275,7 +2275,7 @@ CREATE TABLE `facturacion_media_anual` ( `Id_Cliente` int(11) NOT NULL, `Consumo` double(17,0) DEFAULT NULL, PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `fmaId_Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `fmaId_Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2379,7 +2379,7 @@ CREATE TABLE `rotacion` ( `cm3reparto` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`Id_Article`,`warehouse_id`), KEY `warehouse_id_rotacion_idx` (`warehouse_id`), - CONSTRAINT `id_article_rotaci` FOREIGN KEY (`Id_Article`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `id_article_rotaci` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_id_rotaci` FOREIGN KEY (`warehouse_id`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores de rotacion en los ultimos 365 dias'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2458,7 +2458,7 @@ CREATE TABLE `rutasBoard` ( KEY `rutasBoard_ix1` (`year`), KEY `rutasBoard_ix2` (`month`), KEY `rutasBoard_ix3` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=170826 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=177952 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3251,11 +3251,14 @@ BEGIN -- CLIENTE 7983, JULIAN SUAU UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983; - -- CLIENTE 3504, VAZQUEZ - -- UPDATE bi.claims_ratio SET recobro = GREATEST(0.08, recobro) WHERE Id_Cliente = 3504; + -- CLIENTE 4358 + UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358; -- CLIENTE 5523, VERDECORA - UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; + UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; + + -- CLIENTE 15979, SERVEIS VETERINARIS + UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979; -- CLIENTE 5189 i 8942, son de CSR i son el mateix client UPDATE bi.claims_ratio cr @@ -5081,7 +5084,7 @@ CREATE TABLE `bancos_evolution` ( `saldo_aux` double NOT NULL DEFAULT '0' COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas', PRIMARY KEY (`Fecha`,`Id_Banco`), KEY `fk_banco_evolution_idx` (`Id_Banco`), - CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn2008`.`Bancos` (`Id_Banco`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los saldos bancarios'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -5130,7 +5133,7 @@ CREATE TABLE `clientNewBorn` ( `clientFk` int(11) NOT NULL, `shipped` date NOT NULL, PRIMARY KEY (`clientFk`), - CONSTRAINT `clientNewBorn_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `clientNewBorn_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Listado de clientes que se consideran nuevos a efectos de cobrar la comision adicional del comercial'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -5311,7 +5314,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=305719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=333865 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5373,7 +5376,7 @@ CREATE TABLE `manaCustomer` ( `dated` date NOT NULL, PRIMARY KEY (`Id_Cliente`,`dated`), KEY `manaCustomerIdx1` (`dated`), - CONSTRAINT `cliente_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `cliente_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -5581,9 +5584,9 @@ CREATE TABLE `payMethodClient` ( KEY `FkPayMethod_idx` (`payMethodFk`), KEY `FkClientPayMethod_idx` (`clientFk`), KEY `FkDateClientPayMethod` (`dated`,`clientFk`), - CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4816062 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=5262603 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5657,7 +5660,7 @@ CREATE TABLE `productivity` ( `m3FV` double NOT NULL DEFAULT '0', `m3PCA` double NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=52223278 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=55717733 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5826,9 +5829,9 @@ CREATE TABLE `ventas` ( KEY `clientes_bs_ventas_idx` (`Id_Cliente`), KEY `empresa_bs_ventas_idx` (`empresa_id`), KEY `fecha_bs` (`fecha`), - 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 `clientes_bs_ventas` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `empresa_bs_ventas` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `mov_to_mov` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`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 */; @@ -6380,7 +6383,7 @@ FROM LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND vDate - 1) + AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN (SELECT @@ -7255,96 +7258,6 @@ BEGIN vErrorCode = RETURNED_SQLSTATE; CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`')); -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 `nocturnEvent_Tickets_Bionizar` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `nocturnEvent_Tickets_Bionizar`() -BEGIN -/* - - DECLARE vDone INT DEFAULT FALSE; - DECLARE vId BIGINT; - DECLARE vMaxSaleComponent DATE ; - DECLARE rs CURSOR FOR - SELECT sub.id - FROM (SELECT t.id as ticket,s.id, s.price *(1-(s.discount/100)) as price, SUM(sc.value) AS total, (s.price *(1-(s.discount/100)))- SUM(sc.value) as totales - FROM vn.ticket t - JOIN vn.sale s - ON s.ticketFk=t.id - JOIN vn.item i - ON i.id=s.itemFk - JOIN vn.itemType it - ON i.typeFk=it.id - LEFT JOIN vn.saleComponent sc - ON s.id=sc.saleFk - JOIN vn.warehouse w ON w.id=t.warehouseFk - WHERE t.shipped>=DATE_ADD(CURDATE(), INTERVAL -7 DAY) - AND it.categoryFk<6 - AND t.companyFk=442 - AND w.name!='Inventario' - GROUP BY s.id - HAVING ABS(price-IFNULL(total,0))>0.01 ) AS sub; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - OPEN rs; - - read_loop: LOOP - FETCH rs INTO vId; - - IF vDone THEN - LEAVE read_loop; - END IF; - - CALL vn2008.bionic_calc_movement(vId); - - END LOOP; - CLOSE rs; - - -*/ - - -/* - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - - GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; - SELECT CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto')); - INSERT INTO vn2008.mail (`to`,`subject`,`text`) VALUES ('jgallego@verdnatura.es', 'nocturnEvent_Tickets_Bionizar' ,CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto'))); - INSERT INTO vn2008.mail (`to`,`subject`,`text`) VALUES ('pako@verdnatura.es', 'nocturnEvent_Tickets_Bionizar' ,CONCAT('ERROR ', IFNULL(@errno,0), ': ', ifnull(@text,'texto'))); - -END; -*/ -/* PAK 12/03/2018 No cal rebionitzar. Anem a intentar que els tickets es facen tots correctament. - -SET MyDate = timestampadd(week,-1,curdate()); - -WHILE MyDate < CURDATE() DO - - CALL `vn2008`.`bionic_tickets_range_bionizar`(MyDate, MyDate); - - SET MyDate = timestampadd(DAY,1,MyDate); - - SELECT MyDate; - -END WHILE; -*/ - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7936,7 +7849,7 @@ BEGIN , t.`year` FROM ventas v JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente - JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente + JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND JOIN vn2008.`time` t on t.`date` = v.fecha WHERE c.Id_Trabajador is not null AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter @@ -7984,6 +7897,97 @@ BEGIN call bs.vendedores_evolution_add; +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 `vendedores_add__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `vendedores_add__`(intYEAR INT, vQuarter INT) +BEGIN + + DECLARE comisionRate DOUBLE DEFAULT 0.029; + + REPLACE vendedores + SELECT c.Id_Trabajador + , intYEAR + , MONTH(v.fecha) intMONTH + , sum(importe) as importe + , sum(importe) * 0.029 as comision + , 0 as comisionCedida + , 0 as comisionArrendada + , 0 as comisionNuevos + + FROM ventas v + JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente + JOIN vn2008.`time` t on t.`date` = v.fecha + WHERE c.Id_Trabajador is not null + AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter + GROUP BY c.Id_Trabajador, t.`month`; + + -- Ventas nuevas + UPDATE vendedores v + JOIN + ( + SELECT c.Id_Trabajador + , sum(importe) * 0.029 as comisionNueva + , t.`month` + , t.`year` + FROM ventas v + JOIN bs.clientNewBorn cnb on v.Id_Cliente = cnb.clientFk + JOIN vn2008.Clientes c ON c.Id_Cliente = v.Id_Cliente + JOIN vn2008.`time` t on t.`date` = v.fecha + WHERE c.Id_Trabajador is not null + AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter + GROUP BY c.Id_Trabajador, t.`month` + ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año + SET v.comisionNuevos = sub.comisionNueva, v.comision = v.comision - sub.comisionNueva; + + -- Ventas cedidas + UPDATE vendedores v + JOIN ( + SELECT cc.Id_Trabajador_old as Id_Trabajador + , sum(importe) * 0.029 * comision_old as cedido + , sum(importe) * 0.029 * comision_new as arrendada + , t.`month` + , t.`year` + FROM ventas v + JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente + JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente + JOIN vn2008.`time` t on t.`date` = v.fecha + WHERE c.Id_Trabajador is not null + AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter + GROUP BY cc.Id_Trabajador_old, t.`month` + ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año + SET v.comisionCedida = sub.cedido, v.comision = v.comision - sub.cedido - sub.arrendada; + + -- Ventas arrendadas + UPDATE vendedores v + JOIN ( + SELECT cc.Id_Trabajador_new as Id_Trabajador + , sum(importe) * 0.029 * comision_new as arrendada + , t.`month` + , t.`year` + FROM ventas v + JOIN vn2008.Clientes c on v.Id_Cliente = c.Id_Cliente + JOIN vn2008.Clientes_cedidos cc on cc.Id_Cliente = c.Id_Cliente AND v.fecha between datSTART and datEND + JOIN vn2008.`time` t on t.`date` = v.fecha + WHERE c.Id_Trabajador is not null + AND t.`year` = intYEAR AND QUARTER(v.fecha) = vQuarter + GROUP BY cc.Id_Trabajador_new, t.`month` + ) sub ON sub.Id_Trabajador = v.Id_Trabajador AND sub.`month` = v.mes AND sub.`year` = v.año + SET v.comisionArrendada = sub.arrendada; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8708,7 +8712,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=400709 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=420472 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8776,7 +8780,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=1523534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1736097 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8807,7 +8811,7 @@ CREATE TABLE `visible` ( `item_id` int(11) NOT NULL, `visible` int(11) NOT NULL, UNIQUE KEY `calc_id` (`calc_id`,`item_id`) USING HASH, - KEY `id` (`calc_id`) USING BTREE + KEY `id` (`item_id`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8951,8 +8955,8 @@ proc: BEGIN WHERE t.landing BETWEEN vInventoryDate AND vStartDate AND t.warehouse_id = vWarehouse AND NOT e.Inventario - AND NOT e.Redada - GROUP BY Id_Article + /*AND NOT e.Redada*/ -- JGF cau-13144 2019-10-14 + GROUP BY Id_Article ) c JOIN vn2008.Articles a ON a.Id_Article = c.item_id JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id @@ -9823,7 +9827,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=22072628 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22972859 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9881,7 +9885,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1044352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1074726 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9902,7 +9906,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=586884 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=616189 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10164,7 +10168,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=617032 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=645441 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10420,7 +10424,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=7851941 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8308985 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11044,7 +11048,7 @@ CREATE TABLE `basketOrder` ( UNIQUE KEY `customer_id` (`clientFk`), CONSTRAINT `basketOrder_ibfk_1` FOREIGN KEY (`orderFk`, `clientFk`) REFERENCES `order` (`id`, `customer_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `basketOrder_ibfk_2` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `basketOrder_ibfk_3` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `basketOrder_ibfk_3` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11117,7 +11121,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=155534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=162533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11681,7 +11685,7 @@ CREATE TABLE `news` ( KEY `tag` (`tag`), CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`account` (`id`) ON UPDATE CASCADE, CONSTRAINT `news_ibfk_2` FOREIGN KEY (`tag`) REFERENCES `newsTag` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13065 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13068 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 */ ; @@ -11796,9 +11800,9 @@ CREATE TABLE `order` ( KEY `source_app` (`source_app`), KEY `confirmed` (`confirmed`), 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=2114679 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, + CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2175727 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 */ ; @@ -11860,6 +11864,7 @@ CREATE TABLE `orderConfig` ( `defaultAgencyFk` int(11) DEFAULT NULL, `guestMethod` varchar(45) CHARACTER SET utf8 NOT NULL, `guestAgencyFk` int(11) NOT NULL, + `guestAddressFk` int(11) NOT NULL, `reserveTime` time NOT NULL, `defaultCompanyFk` smallint(6) unsigned DEFAULT NULL, PRIMARY KEY (`id`), @@ -11868,10 +11873,12 @@ CREATE TABLE `orderConfig` ( KEY `defaultCompanyFk` (`defaultCompanyFk`), KEY `guestMethod` (`guestMethod`), KEY `defaultAgencyFk` (`defaultAgencyFk`), + KEY `guestAddressFk` (`guestAddressFk`), CONSTRAINT `orderConfig_ibfk_1` FOREIGN KEY (`employeeFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `orderConfig_ibfk_2` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE, - CONSTRAINT `orderConfig_ibfk_3` FOREIGN KEY (`guestAgencyFk`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON UPDATE CASCADE, - CONSTRAINT `orderConfig_ibfk_4` FOREIGN KEY (`defaultAgencyFk`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) + CONSTRAINT `orderConfig_ibfk_2` FOREIGN KEY (`defaultCompanyFk`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `orderConfig_ibfk_3` FOREIGN KEY (`guestAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `orderConfig_ibfk_4` FOREIGN KEY (`defaultAgencyFk`) REFERENCES `vn`.`agencyMode` (`id`), + CONSTRAINT `orderConfig_ibfk_5` FOREIGN KEY (`guestAddressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11912,9 +11919,9 @@ CREATE TABLE `orderRow` ( KEY `order_id` (`orderFk`), KEY `created` (`created`), KEY `warehouse_shipment` (`warehouseFk`,`shipment`), - CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, + CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12741800 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13100407 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 */ ; @@ -12336,9 +12343,9 @@ CREATE TABLE `tpvTransaction` ( KEY `response` (`response`), KEY `error_code` (`errorCode`), 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_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=348669 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=359597 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12373,7 +12380,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=1922127 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1958131 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12393,7 +12400,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=4245996 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4346138 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12418,7 +12425,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=2550495 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2593055 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12438,7 +12445,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=3724600 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3809843 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -13291,15 +13298,23 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `myBasket_configureForGuest`() BEGIN - DECLARE vMethod VARCHAR(45); + DECLARE vMethod VARCHAR(255); DECLARE vAgency INT; + DECLARE vAddress INT; + DECLARE vDate DATE; - SELECT guestMethod, guestAgencyFk - INTO vMethod, vAgency + SELECT guestMethod, guestAgencyFk, guestAddressFk + INTO vMethod, vAgency, vAddress FROM orderConfig LIMIT 1; + + SET vDate = TIMESTAMPADD(DAY, 1, CURDATE()); - CALL myBasket_configure(CURDATE(), vMethod, vAgency, NULL); + IF WEEKDAY(vDate) BETWEEN 5 AND 6 THEN + SET vDate = TIMESTAMPADD(DAY, 7 - WEEKDAY(vDate), vDate); + END IF; + + CALL myBasket_configure(vDate, vMethod, vAgency, vAddress); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -15917,7 +15932,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDB AUTO_INCREMENT=298064 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=306064 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16748,7 +16763,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=865 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=930 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16803,7 +16818,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=2762 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2914 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16942,7 +16957,7 @@ CREATE TABLE `calendar_labour_type` ( `hours_week` smallint(6) DEFAULT NULL, PRIMARY KEY (`calendar_labour_type_id`), UNIQUE KEY `hours_labour_hours_labour_id_key` (`calendar_labour_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16961,7 +16976,7 @@ CREATE TABLE `calendar_state` ( `code` varchar(45) DEFAULT NULL, `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`calendar_state_id`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17017,7 +17032,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=70134 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=72197 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17051,7 +17066,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=2144 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2413 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17087,7 +17102,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=1063 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1145 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17167,7 +17182,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=1100 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1165 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17218,7 +17233,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=983 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1049 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17254,7 +17269,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=1221 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1305 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17394,7 +17409,7 @@ CREATE TABLE `ACL` ( `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=197 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=202 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17514,7 +17529,7 @@ CREATE TABLE `userConfigView` ( `configuration` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `uniqueUser_TableCode` (`userFk`,`tableCode`) -) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19320,6 +19335,122 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `compareObjects` */; +/*!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 `compareObjects`(vChain VARCHAR(45),vCompare VARCHAR(45)) + READS SQL DATA +BEGIN +/** + * Devuelve un listado de todos los procedimientos, funciones + * eventos, disparadores y vistas que estan incluidos en las dos cadenadas dadas. + * + * Es util para buscar una columna de una tabla en concreto + * @param vChain Cadena a buscar + * @param vCompare Cadena a buscar y comparar los resultados con la primera cadena + * @select Listado de objetos + */ + SET vChain = CONCAT('%', vChain, '%'); + SET vCompare = CONCAT('%', vCompare, '%'); + SELECT * FROM + ( + SELECT t1.* FROM + ( + SELECT + `db`, + `name`, + `type`, + `body`, + `created`, + `modified` + FROM `mysql`.`proc` + WHERE `body` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `db`, + `name`, + 'EVENT', + `body_utf8`, + `created`, + `modified` + FROM `mysql`.`event` + WHERE `body_utf8` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `EVENT_OBJECT_SCHEMA`, + `TRIGGER_NAME`, + 'TRIGGER', + `ACTION_STATEMENT`, + NULL, + NULL + FROM `information_schema`.`TRIGGERS` + WHERE `ACTION_STATEMENT` LIKE vChain COLLATE utf8_general_ci + UNION ALL + SELECT + `TABLE_SCHEMA`, + `TABLE_NAME`, + 'VIEW', + `VIEW_DEFINITION`, + NULL, + NULL + FROM `information_schema`.`VIEWS` + WHERE `VIEW_DEFINITION` LIKE vChain COLLATE utf8_general_ci + ) t1 + JOIN ( + SELECT + `db`, + `name`, + `type`, + `body`, + `created`, + `modified` + FROM `mysql`.`proc` + WHERE `body` LIKE vCompare COLLATE utf8_general_ci + UNION ALL + SELECT + `db`, + `name`, + 'EVENT', + `body_utf8`, + `created`, + `modified` + FROM `mysql`.`event` + WHERE `body_utf8` LIKE vCompare COLLATE utf8_general_ci + UNION ALL + SELECT + `EVENT_OBJECT_SCHEMA`, + `TRIGGER_NAME`, + 'TRIGGER', + `ACTION_STATEMENT`, + NULL, + NULL + FROM `information_schema`.`TRIGGERS` + WHERE `ACTION_STATEMENT` LIKE vCompare COLLATE utf8_general_ci + UNION ALL + SELECT + `TABLE_SCHEMA`, + `TABLE_NAME`, + 'VIEW', + `VIEW_DEFINITION`, + NULL, + NULL + FROM `information_schema`.`VIEWS` + WHERE `VIEW_DEFINITION` LIKE vCompare COLLATE utf8_general_ci) t2 ON t2.name = t1.name + ORDER BY t1.`db`, t1.`name` + ) t; +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 `debugAdd` */; ALTER DATABASE `util` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -19513,105 +19644,39 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf USE `vn`; -- --- Temporary table structure for view `__addressObservation` +-- Temporary table structure for view `__taxClassCode` -- -DROP TABLE IF EXISTS `__addressObservation`; -/*!50001 DROP VIEW IF EXISTS `__addressObservation`*/; +DROP TABLE IF EXISTS `__taxClassCode`; +/*!50001 DROP VIEW IF EXISTS `__taxClassCode`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `__addressObservation` AS SELECT - 1 AS `id`, - 1 AS `addressFk`, - 1 AS `observationTypeFk`, - 1 AS `description`*/; +/*!50001 CREATE VIEW `__taxClassCode` AS SELECT + 1 AS `taxClassFk`, + 1 AS `effectived`, + 1 AS `taxCodeFk`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `__clientCredit` +-- Temporary table structure for view `__taxCode` -- -DROP TABLE IF EXISTS `__clientCredit`; -/*!50001 DROP VIEW IF EXISTS `__clientCredit`*/; +DROP TABLE IF EXISTS `__taxCode`; +/*!50001 DROP VIEW IF EXISTS `__taxCode`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `__clientCredit` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `workerFk`, - 1 AS `amount`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `__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 +/*!50001 CREATE VIEW `__taxCode` AS SELECT 1 AS `id`, + 1 AS `dated`, 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`*/; + 1 AS `taxTypeFk`, + 1 AS `rate`, + 1 AS `equalizationTax`, + 1 AS `type`, + 1 AS `link`, + 1 AS `isActive`, + 1 AS `updated`, + 1 AS `transactionCode`*/; SET character_set_client = @saved_cs_client; -- @@ -19687,7 +19752,7 @@ CREATE TABLE `activityTaxDismissed` ( `isDismissed` tinyint(1) DEFAULT '0', `notified` int(11) DEFAULT '0', PRIMARY KEY (`clientFk`), - CONSTRAINT `clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -19750,53 +19815,100 @@ CREATE TABLE `addressObservation` ( 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 `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'; +) ENGINE=InnoDB AUTO_INCREMENT=4108 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `agency` +-- Temporary table structure for view `addressObservation__` +-- + +DROP TABLE IF EXISTS `addressObservation__`; +/*!50001 DROP VIEW IF EXISTS `addressObservation__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `addressObservation__` AS SELECT + 1 AS `id`, + 1 AS `addressFk`, + 1 AS `observationTypeFk`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `agency` -- DROP TABLE IF EXISTS `agency`; -/*!50001 DROP VIEW IF EXISTS `agency`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `agency` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `warehouseFk`, - 1 AS `isVolumetric`, - 1 AS `bankFk`, - 1 AS `warehouseAliasFk`, - 1 AS `isOwn`, - 1 AS `labelZone`, - 1 AS `workCenterFk`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agency` ( + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes', + `isVolumetric` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen', + `bankFk` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos', + `warehouseAliasFk` smallint(5) unsigned DEFAULT NULL, + `isOwn` tinyint(1) NOT NULL DEFAULT '0', + `labelZone` tinyint(4) NOT NULL DEFAULT '0', + `workCenterFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `warehouse_id` (`warehouseFk`), + KEY `Id_Banco` (`bankFk`), + KEY `agencias_alias_idx` (`warehouseAliasFk`), + KEY `agency_ibfk_3_idx` (`workCenterFk`), + CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=282 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`.`agency_afterInsert` AFTER INSERT ON `vn`.`agency` FOR EACH ROW +BEGIN + INSERT INTO agencyMode(name,agencyFk) VALUES(NEW.name,NEW.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 */ ; -- --- Temporary table structure for view `agencyMode` +-- Table structure for table `agencyMode` -- DROP TABLE IF EXISTS `agencyMode`; -/*!50001 DROP VIEW IF EXISTS `agencyMode`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `agencyMode` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `description`, - 1 AS `deliveryMethodFk`, - 1 AS `m3`, - 1 AS `cod71`, - 1 AS `web`, - 1 AS `agencyFk`, - 1 AS `agencyServiceFk`, - 1 AS `inflation`, - 1 AS `isVolumetric`, - 1 AS `reportMail`, - 1 AS `isActive`, - 1 AS `code`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agencyMode` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `deliveryMethodFk` int(11) DEFAULT '0', + `m3` double DEFAULT '0', + `cod71` tinyint(3) unsigned DEFAULT '0', + `web` smallint(1) unsigned zerofill NOT NULL DEFAULT '0', + `agencyFk` smallint(6) NOT NULL, + `agencyServiceFk` tinyint(4) NOT NULL DEFAULT '1', + `inflation` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', + `isVolumetric` tinyint(1) NOT NULL DEFAULT '0', + `reportMail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `showAgencyName` tinyint(1) DEFAULT '1' COMMENT 'obsoleta', + `isActive` tinyint(1) NOT NULL DEFAULT '1', + `isExternalAgency` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta', + `flag` blob COMMENT 'obsoleta', + `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `Agencias` (`name`), + KEY `Vista` (`deliveryMethodFk`) +) ENGINE=InnoDB AUTO_INCREMENT=1233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Temporary table structure for view `agencyModeZone` @@ -19816,6 +19928,34 @@ SET character_set_client = utf8; 1 AS `inflation`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `agencyMode__` +-- + +DROP TABLE IF EXISTS `agencyMode__`; +/*!50001 DROP VIEW IF EXISTS `agencyMode__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agencyMode__` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `description`, + 1 AS `deliveryMethodFk`, + 1 AS `m3`, + 1 AS `cod71`, + 1 AS `web`, + 1 AS `agencyFk`, + 1 AS `agencyServiceFk`, + 1 AS `inflation`, + 1 AS `isVolumetric`, + 1 AS `reportMail`, + 1 AS `isActive`, + 1 AS `code`, + 1 AS `showAgencyName`, + 1 AS `isExternalAgency`, + 1 AS `flag`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `agencyProvince` -- @@ -19846,6 +19986,26 @@ SET character_set_client = utf8; 1 AS `agencyType`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `agency__` +-- + +DROP TABLE IF EXISTS `agency__`; +/*!50001 DROP VIEW IF EXISTS `agency__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agency__` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `warehouseFk`, + 1 AS `isVolumetric`, + 1 AS `bankFk`, + 1 AS `warehouseAliasFk`, + 1 AS `isOwn`, + 1 AS `labelZone`, + 1 AS `workCenterFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `alertLevel` -- @@ -19857,7 +20017,7 @@ CREATE TABLE `alertLevel` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, `alertLevel` int(11) NOT NULL, PRIMARY KEY (`code`), - CONSTRAINT `fk_code_1` FOREIGN KEY (`code`) REFERENCES `vn2008`.`state` (`code`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `fk_code_1` FOREIGN KEY (`code`) REFERENCES `state` (`code`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -19925,8 +20085,8 @@ CREATE TABLE `autoRadioLogCall` ( `response` longtext COLLATE utf8_unicode_ci NOT NULL, 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=1265 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=1424 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19943,7 +20103,7 @@ CREATE TABLE `autonomousRegion` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `countryFk` (`countryFk`), - CONSTRAINT `countryFk` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `countryFk` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -19981,22 +20141,30 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `bank` +-- Table structure for table `bank` -- DROP TABLE IF EXISTS `bank`; -/*!50001 DROP VIEW IF EXISTS `bank`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `bank` AS SELECT - 1 AS `id`, - 1 AS `bank`, - 1 AS `account`, - 1 AS `cash`, - 1 AS `entityFk`, - 1 AS `isActive`, - 1 AS `currencyFk`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bank` ( + `id` int(11) NOT NULL DEFAULT '0', + `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `cash` smallint(6) NOT NULL DEFAULT '0', + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1', + `entityFk` int(10) unsigned NOT NULL, + `isActive` tinyint(4) NOT NULL DEFAULT '1', + `currencyFk` tinyint(3) unsigned DEFAULT '1', + PRIMARY KEY (`id`), + KEY `BancosBanco` (`bank`), + KEY `fk_Bancos_entity1_idx` (`entityFk`), + KEY `foreignkey1_idx` (`cash`), + KEY `Bancoscurrency_idx` (`currencyFk`), + CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE, + CONSTRAINT `foreignkey1` FOREIGN KEY (`cash`) REFERENCES `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 */; -- -- Table structure for table `bankEntity` @@ -20013,8 +20181,8 @@ CREATE TABLE `bankEntity` ( 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 '; + CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=30050 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20032,6 +20200,24 @@ SET character_set_client = utf8; 1 AS `bic`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `bank__` +-- + +DROP TABLE IF EXISTS `bank__`; +/*!50001 DROP VIEW IF EXISTS `bank__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `bank__` AS SELECT + 1 AS `id`, + 1 AS `bank`, + 1 AS `account`, + 1 AS `cash`, + 1 AS `entityFk`, + 1 AS `isActive`, + 1 AS `currencyFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `bookingPlanner` -- @@ -20054,9 +20240,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 ON UPDATE CASCADE, - CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `bookingPlanner_ibfk_2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20078,14 +20264,28 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `businessReasonEnd` +-- Table structure for table `businessReasonEnd` -- DROP TABLE IF EXISTS `businessReasonEnd`; -/*!50001 DROP VIEW IF EXISTS `businessReasonEnd`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `businessReasonEnd` ( + `id` tinyint(3) NOT NULL AUTO_INCREMENT, + `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `businessReasonEnd__` +-- + +DROP TABLE IF EXISTS `businessReasonEnd__`; +/*!50001 DROP VIEW IF EXISTS `businessReasonEnd__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `businessReasonEnd` AS SELECT +/*!50001 CREATE VIEW `businessReasonEnd__` AS SELECT 1 AS `id`, 1 AS `reason`*/; SET character_set_client = @saved_cs_client; @@ -20127,7 +20327,7 @@ CREATE TABLE `buy` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `__cm2` int(10) unsigned NOT NULL DEFAULT '0', `ektFk` int(11) DEFAULT NULL, - `weight` int(11) unsigned DEFAULT NULL, + `weight` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `CompresId_Trabajador` (`workerFk`), KEY `Id_Cubo` (`packageFk`), @@ -20135,12 +20335,12 @@ CREATE TABLE `buy` ( KEY `container_id` (`containerFk`), KEY `buy_edi_id` (`ektFk`), KEY `itemFk_entryFk` (`itemFk`,`entryFk`), - CONSTRAINT `buy_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, - CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packageFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE, + CONSTRAINT `buy_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `buy_ibfk_2` FOREIGN KEY (`packageFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, 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=336356382 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; + CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=343287549 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 */ ; @@ -20245,9 +20445,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 ;; @@ -20255,7 +20455,7 @@ DELIMITER ;; AFTER UPDATE ON `buy` FOR EACH ROW trig: BEGIN - IF !(NEW.id <=> OLD.id) + IF !(NEW.id <=> OLD.id) OR !(NEW.entryFk <=> OLD.entryFk) OR !(NEW.itemFk <=> OLD.itemFk) OR !(NEW.quantity <=> OLD.quantity) @@ -20269,9 +20469,9 @@ trig: BEGIN CALL buy_afterUpsert(NEW.id); - IF !(NEW.weight <=> OLD.weight) THEN + IF !(NEW.weight <=> OLD.weight) OR !(NEW.packing <=> OLD.packing) OR !(NEW.packageFk <=> OLD.packageFk) THEN UPDATE item - SET density = (NEW.weight * NEW.packing) / (item_getVolume(NEW.itemFk, NEW.packageFk) / 1000) + SET density = NEW.weight / (item_getVolume(NEW.itemFk, NEW.packageFk) / 1000000) WHERE id = NEW.itemFk; END IF; END */;; @@ -20324,6 +20524,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `buyMark` +-- + +DROP TABLE IF EXISTS `buyMark`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `buyMark` ( + `id` int(11) NOT NULL, + `comment` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `mark` tinyint(1) DEFAULT NULL, + `odbcDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`id`) REFERENCES `buy` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `calendarHolidays` -- @@ -20357,7 +20574,7 @@ CREATE TABLE `calendarHolidaysName` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20429,11 +20646,11 @@ CREATE TABLE `claim` ( 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 `cl_main_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) 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'; + CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=69135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20453,9 +20670,9 @@ CREATE TABLE `claimBeginning` ( 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_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=150836 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=152813 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 */ ; @@ -20565,7 +20782,7 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_7` FOREIGN KEY (`claimReasonFk`) REFERENCES `claimReason` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_8` FOREIGN KEY (`claimResultFk`) REFERENCES `claimResult` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59053 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=59853 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20623,10 +20840,10 @@ CREATE TABLE `claimEnd` ( 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_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) 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'; +) ENGINE=InnoDB AUTO_INCREMENT=116375 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20654,7 +20871,7 @@ DROP TABLE IF EXISTS `claimLog`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `claimLog` ( - `id` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, `originFk` int(10) unsigned NOT NULL, `userFk` int(10) unsigned DEFAULT NULL, `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, @@ -20670,7 +20887,7 @@ CREATE TABLE `claimLog` ( KEY `userFk` (`userFk`), CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1710 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20854,14 +21071,560 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `client` +-- Table structure for table `client` -- DROP TABLE IF EXISTS `client`; -/*!50001 DROP VIEW IF EXISTS `client`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `client` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `discount` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `defaultAddressFk` int(11) DEFAULT NULL, + `street` longtext COLLATE utf8_unicode_ci, + `fi` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `fax` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `email` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `dueDay` smallint(6) NOT NULL DEFAULT '5', + `receipt` int(11) DEFAULT '1' COMMENT 'obsoleta', + `isOfficial` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'obsoleta (comprobar)', + `isTaxDataChecked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', + `mobile` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `accountingAccount` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `isEqualizated` tinyint(1) NOT NULL DEFAULT '0', + `city` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, + `provinceFk` smallint(5) unsigned DEFAULT NULL, + `postcode` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL, + `socialName` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, + `contact` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `wholesaler` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `isReExpedition` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hasToInvoice` tinyint(1) NOT NULL DEFAULT '1', + `notes` text COLLATE utf8_unicode_ci COMMENT 'obsoleta (comprobar)', + `administrativeNotes` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'obsoleta (comprobar)', + `invoiceCopy` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hold` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `isFreezed` tinyint(1) NOT NULL DEFAULT '0', + `salesPersonFk` int(11) DEFAULT NULL, + `credit` decimal(10,2) NOT NULL DEFAULT '0.00', + `cyc` double DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `isActive` tinyint(1) NOT NULL DEFAULT '1', + `gestdocFk` int(11) DEFAULT NULL, + `quality` int(2) DEFAULT '11', + `payMethodFk` tinyint(3) unsigned NOT NULL DEFAULT '5', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isToBeMailed` tinyint(1) NOT NULL DEFAULT '1', + `contactChannelFk` smallint(6) DEFAULT NULL, + `isVies` tinyint(4) NOT NULL DEFAULT '0', + `splitHolland` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `sepaFth` tinyint(1) DEFAULT '0' COMMENT 'campo para recibir los escritos de los clientes para el sepa\n\nobsoleta (comprobar)', + `hasSepaVnl` tinyint(1) DEFAULT '0', + `coreFth` tinyint(1) DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `hasCoreVnl` tinyint(1) DEFAULT '0', + `riskCalculated` date NOT NULL, + `hasCoreVnh` tinyint(1) DEFAULT '0', + `isRelevant` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', + `clientTypeFk` int(11) NOT NULL DEFAULT '1', + `postcodeOld` int(11) unsigned DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `mailAddress` int(11) DEFAULT NULL, + `codposOLD` char(5) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta (comprobar)', + `creditInsurance` int(11) DEFAULT NULL, + `eypbc` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Email\\nYesterday\\nPurchases\\nBy\\nConsigna', + `hasToInvoiceByAddress` tinyint(1) DEFAULT '0', + `cplusTerIdNifFk` int(11) NOT NULL DEFAULT '1' COMMENT 'OBSOLETO', + `isCreatedAsServed` tinyint(1) DEFAULT '0', + `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0', + `iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL, + `hasLcr` tinyint(1) NOT NULL DEFAULT '0', + `bankEntityFk` int(10) DEFAULT NULL, + `typeFk` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT 'normal', + PRIMARY KEY (`id`), + UNIQUE KEY `IF` (`fi`), + KEY `Id_Trabajador` (`salesPersonFk`), + KEY `Id_Pais` (`countryFk`), + KEY `pay_met_id` (`payMethodFk`), + KEY `canal_nuevo_cliente` (`contactChannelFk`), + KEY `Cuenta` (`accountingAccount`), + KEY `province_id` (`provinceFk`), + KEY `default_address` (`defaultAddressFk`), + KEY `Telefono` (`phone`), + KEY `movil` (`mobile`), + KEY `tipos_de_cliente_idx` (`clientTypeFk`), + KEY `codpos` (`codposOLD`,`postcode`), + KEY `fk_Clientes_entity_idx` (`bankEntityFk`), + KEY `typeFk` (`typeFk`), + CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_2` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_3` FOREIGN KEY (`salesPersonFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_4` FOREIGN KEY (`defaultAddressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, + CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=16657 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`.`client_beforeInsert` + BEFORE INSERT ON `client` + FOR EACH ROW +BEGIN + DECLARE isAlreadyUsedIf BOOL; + + SELECT COUNT(*) INTO isAlreadyUsedIf + FROM client + WHERE `fi` = TRIM(NEW.`fi`); + + IF isAlreadyUsedIf THEN + CALL util.throw('El NIF/CIF está repetido'); + END IF; + + CALL pbx.phone_isValid(NEW.phone); + CALL pbx.phone_isValid(NEW.mobile); + CALL pbx.phone_isValid(NEW.fax); + + SET NEW.accountingAccount = 4300000000 + NEW.id; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = 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`.`client_beforeUpdate` + BEFORE UPDATE ON `client` + FOR EACH ROW +BEGIN + DECLARE vText VARCHAR(255) DEFAULT NULL; + DECLARE isAlreadyUsedIf BOOL; + + SELECT (COUNT(*) > 1) INTO isAlreadyUsedIf + FROM client + WHERE `fi` = TRIM(NEW.`fi`); + + IF isAlreadyUsedIf THEN + CALL util.throw('El NIF/CIF está repetido'); + END IF; + + -- Comprueba que el formato de los teléfonos es válido + + IF !(NEW.phone <=> OLD.phone) THEN + CALL pbx.phone_isValid(NEW.phone); + END IF; + + IF !(NEW.mobile <=> OLD.mobile) THEN + CALL pbx.phone_isValid(NEW.mobile); + END IF; + + IF !(NEW.fax <=> OLD.fax) THEN + CALL pbx.phone_isValid(NEW.fax); + END IF; + + IF NEW.payMethodFk = 4 AND NEW.dueDay = 0 THEN + SET NEW.dueDay = 5; + END IF; + + -- Avisar al comercial si ha llegado la documentación sepa/core + + IF NEW.hasSepaVnl AND !OLD.hasSepaVnl THEN + SET vText = 'Sepa de VNL'; + END IF; + + IF NEW.hasCoreVnl AND !OLD.hasCoreVnl THEN + SET vText = 'Core de VNL'; + END IF; + + IF vText IS NOT NULL + THEN + INSERT INTO vn2008.mail(`to`, reply_to, subject, text) + SELECT + CONCAT(IF(ac.id,u.name, 'jgallego'), '@verdnatura.es'), + 'administracion@verdnatura.es', + CONCAT('Cliente ', NEW.id), + CONCAT('Recibida la documentación: ', vText) + FROM worker w + LEFT JOIN account.user u ON w.userFk = u.id AND u.active + LEFT JOIN account.account ac ON ac.id = u.id + WHERE w.id = NEW.salesPersonFk; + 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`.`client_afterUpdate` +AFTER UPDATE ON `client` +FOR EACH ROW +BEGIN + IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN + UPDATE `address` SET isDefaultAddress = 0 + WHERE clientFk = NEW.id; + + UPDATE `address` SET isDefaultAddress = 1 + WHERE id = NEW.defaultAddressFk; + 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 `clientChain` +-- + +DROP TABLE IF EXISTS `clientChain`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientChain` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `chainFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `clientChain_fk1_idx` (`clientFk`), + KEY `clientChain_fk2_idx` (`chainFk`), + CONSTRAINT `clientChain_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientChain_fk2` FOREIGN KEY (`chainFk`) REFERENCES `chain` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `clientContact` +-- + +DROP TABLE IF EXISTS `clientContact`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientContact` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `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=4148 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `clientCredit` +-- + +DROP TABLE IF EXISTS `clientCredit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientCredit` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `amount` double unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `workerFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `workers_fk_idx` (`workerFk`), + KEY `credit_ClienteFk` (`clientFk`), + CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=82635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `clientCreditLimit` +-- + +DROP TABLE IF EXISTS `clientCreditLimit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientCreditLimit` ( + `id` int(11) NOT NULL, + `maxAmount` int(10) unsigned NOT NULL, + `roleFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientCredit__` +-- + +DROP TABLE IF EXISTS `clientCredit__`; +/*!50001 DROP VIEW IF EXISTS `clientCredit__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `client` AS SELECT +/*!50001 CREATE VIEW `clientCredit__` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `workerFk`, + 1 AS `amount`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `clientDefaultCompany` +-- + +DROP TABLE IF EXISTS `clientDefaultCompany`; +/*!50001 DROP VIEW IF EXISTS `clientDefaultCompany`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientDefaultCompany` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `companyFk`, + 1 AS `started`, + 1 AS `finished`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientDms` +-- + +DROP TABLE IF EXISTS `clientDms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientDms` ( + `clientFk` int(11) NOT NULL, + `dmsFk` int(11) NOT NULL, + PRIMARY KEY (`dmsFk`), + KEY `gest_doc_id` (`dmsFk`), + KEY `fk_clientes_gestdoc_1_idx` (`clientFk`), + CONSTRAINT `clientDms_ibfk_2` FOREIGN KEY (`dmsFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientDms__` +-- + +DROP TABLE IF EXISTS `clientDms__`; +/*!50001 DROP VIEW IF EXISTS `clientDms__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientDms__` AS SELECT + 1 AS `clientFk`, + 1 AS `dmsFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientLog` +-- + +DROP TABLE IF EXISTS `clientLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) NOT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text CHARACTER SET utf8, + `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `oldInstance` text COLLATE utf8_unicode_ci, + `newInstance` text COLLATE utf8_unicode_ci, + `changedModelId` int(11) DEFAULT NULL, + `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `originFk` (`originFk`), + KEY `userFk` (`userFk`), + CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=231874 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientManaCache` +-- + +DROP TABLE IF EXISTS `clientManaCache`; +/*!50001 DROP VIEW IF EXISTS `clientManaCache`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientManaCache` AS SELECT + 1 AS `clientFk`, + 1 AS `mana`, + 1 AS `dated`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientObservation` +-- + +DROP TABLE IF EXISTS `clientObservation`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `workerFk` int(11) NOT NULL, + `text` text COLLATE utf8_unicode_ci NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `Id_Trabajador` (`workerFk`), + KEY `Id_Cliente` (`clientFk`), + CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=77629 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientObservation__` +-- + +DROP TABLE IF EXISTS `clientObservation__`; +/*!50001 DROP VIEW IF EXISTS `clientObservation__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientObservation__` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `workerFk`, + 1 AS `text`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientProtected` +-- + +DROP TABLE IF EXISTS `clientProtected`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientProtected` ( + `clientFk` int(11) NOT NULL, + `workerFk` int(11) NOT NULL, + `isValidated` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`clientFk`), + KEY `clientProtected_fk2_idx` (`workerFk`), + CONSTRAINT `clientProtected_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientProtected_fk2` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientRisk` +-- + +DROP TABLE IF EXISTS `clientRisk`; +/*!50001 DROP VIEW IF EXISTS `clientRisk`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientRisk` AS SELECT + 1 AS `clientFk`, + 1 AS `companyFk`, + 1 AS `amount`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientSample` +-- + +DROP TABLE IF EXISTS `clientSample`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientSample` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `clientFk` int(10) unsigned NOT NULL, + `typeFk` int(10) unsigned NOT NULL, + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `workerFk` int(10) unsigned NOT NULL, + `balance` float NOT NULL, + `companyFk` smallint(5) unsigned DEFAULT NULL, + `userFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `empresa_id` (`companyFk`), + CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=18322 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientSample__` +-- + +DROP TABLE IF EXISTS `clientSample__`; +/*!50001 DROP VIEW IF EXISTS `clientSample__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientSample__` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `typeFk`, + 1 AS `created`, + 1 AS `workerFk`, + 1 AS `userFk`, + 1 AS `companyFk`, + 1 AS `balance`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `clientType` +-- + +DROP TABLE IF EXISTS `clientType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(20) CHARACTER SET utf8 NOT NULL, + `type` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `isCreatedAsServed` tinyint(1) DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `code_UNIQUE` (`code`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `clientType__` +-- + +DROP TABLE IF EXISTS `clientType__`; +/*!50001 DROP VIEW IF EXISTS `clientType__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientType__` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `type`, + 1 AS `isCreatedAsServed`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `client__` +-- + +DROP TABLE IF EXISTS `client__`; +/*!50001 DROP VIEW IF EXISTS `client__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `client__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `fi`, @@ -20874,7 +21637,7 @@ SET character_set_client = utf8; 1 AS `mobile`, 1 AS `fax`, 1 AS `isRelevant`, - 1 AS `email`, + 1 AS `e-mail`, 1 AS `iban`, 1 AS `dueDay`, 1 AS `accountingAccount`, @@ -20909,229 +21672,23 @@ SET character_set_client = utf8; 1 AS `isVies`, 1 AS `eypbc`, 1 AS `bankEntityFk`, - 1 AS `typeFk`*/; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `clientChain` --- - -DROP TABLE IF EXISTS `clientChain`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientChain` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL, - `chainFk` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `clientChain_fk1_idx` (`clientFk`), - KEY `clientChain_fk2_idx` (`chainFk`), - CONSTRAINT `clientChain_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `clientChain_fk2` FOREIGN KEY (`chainFk`) REFERENCES `chain` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `clientContact` --- - -DROP TABLE IF EXISTS `clientContact`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientContact` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL, - `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=4142 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `clientCredit` --- - -DROP TABLE IF EXISTS `clientCredit`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientCredit` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `clientFk` int(11) NOT NULL, - `amount` double unsigned NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `workerFk` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `workers_fk_idx` (`workerFk`), - 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=81334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `clientCreditLimit` --- - -DROP TABLE IF EXISTS `clientCreditLimit`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientCreditLimit` ( - `id` int(11) NOT NULL, - `maxAmount` int(10) unsigned NOT NULL, - `roleFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `clientDefaultCompany` --- - -DROP TABLE IF EXISTS `clientDefaultCompany`; -/*!50001 DROP VIEW IF EXISTS `clientDefaultCompany`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientDefaultCompany` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `companyFk`, - 1 AS `started`, - 1 AS `finished`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `clientDms` --- - -DROP TABLE IF EXISTS `clientDms`; -/*!50001 DROP VIEW IF EXISTS `clientDms`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientDms` AS SELECT - 1 AS `clientFk`, - 1 AS `dmsFk`*/; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `clientLog` --- - -DROP TABLE IF EXISTS `clientLog`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientLog` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `originFk` int(11) NOT NULL, - `userFk` int(10) unsigned DEFAULT NULL, - `action` set('insert','update','delete') COLLATE utf8_unicode_ci NOT NULL, - `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `description` text CHARACTER SET utf8, - `changedModel` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `oldInstance` text COLLATE utf8_unicode_ci, - `newInstance` text COLLATE utf8_unicode_ci, - `changedModelId` int(11) DEFAULT NULL, - `changedModelValue` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `originFk` (`originFk`), - 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=225760 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `clientManaCache` --- - -DROP TABLE IF EXISTS `clientManaCache`; -/*!50001 DROP VIEW IF EXISTS `clientManaCache`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientManaCache` AS SELECT - 1 AS `clientFk`, - 1 AS `mana`, - 1 AS `dated`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `clientObservation` --- - -DROP TABLE IF EXISTS `clientObservation`; -/*!50001 DROP VIEW IF EXISTS `clientObservation`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientObservation` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `workerFk`, - 1 AS `text`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `clientProtected` --- - -DROP TABLE IF EXISTS `clientProtected`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientProtected` ( - `clientFk` int(11) NOT NULL, - `workerFk` int(11) NOT NULL, - `isValidated` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`clientFk`), - KEY `clientProtected_fk2_idx` (`workerFk`), - CONSTRAINT `clientProtected_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `clientProtected_fk2` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `clientRisk` --- - -DROP TABLE IF EXISTS `clientRisk`; -/*!50001 DROP VIEW IF EXISTS `clientRisk`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientRisk` AS SELECT - 1 AS `clientFk`, - 1 AS `companyFk`, - 1 AS `amount`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `clientSample` --- - -DROP TABLE IF EXISTS `clientSample`; -/*!50001 DROP VIEW IF EXISTS `clientSample`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientSample` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, 1 AS `typeFk`, - 1 AS `created`, - 1 AS `workerFk`, - 1 AS `userFk`, - 1 AS `companyFk`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `clientType` --- - -DROP TABLE IF EXISTS `clientType`; -/*!50001 DROP VIEW IF EXISTS `clientType`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientType` AS SELECT - 1 AS `id`, - 1 AS `code`, - 1 AS `type`, - 1 AS `isCreatedAsServed`*/; + 1 AS `receipt`, + 1 AS `cc`, + 1 AS `discount`, + 1 AS `isOfficial`, + 1 AS `wholesaler`, + 1 AS `isReExpedition`, + 1 AS `notes`, + 1 AS `administrativeNotes`, + 1 AS `invoiceCopy`, + 1 AS `hold`, + 1 AS `cyc`, + 1 AS `splitHolland`, + 1 AS `sepaFth`, + 1 AS `coreFth`, + 1 AS `postcodeOLD`, + 1 AS `codposOLD`*/; SET character_set_client = @saved_cs_client; -- @@ -21148,26 +21705,45 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `company` +-- Table structure for table `company` -- DROP TABLE IF EXISTS `company`; -/*!50001 DROP VIEW IF EXISTS `company`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `company` AS SELECT - 1 AS `id`, - 1 AS `code`, - 1 AS `supplierAccountFk`, - 1 AS `workerManagerFk`, - 1 AS `sage200Company`, - 1 AS `footnotes`, - 1 AS `phytosanitary`, - 1 AS `companyCode`, - 1 AS `companyGroupFk`, - 1 AS `isDefaulter`, - 1 AS `expired`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `company` ( + `id` smallint(5) unsigned NOT NULL, + `code` char(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `register` varchar(120) COLLATE utf8_unicode_ci NOT NULL, + `workerManagerFk` int(11) NOT NULL, + `registered` date NOT NULL, + `expired` date DEFAULT NULL, + `logo` longblob, + `isOfficial` tinyint(1) unsigned NOT NULL DEFAULT '1', + `hasCyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `rgb` varchar(6) COLLATE utf8_unicode_ci NOT NULL, + `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `stamp` blob, + `created` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP, + `clientFk` int(11) DEFAULT NULL, + `sage200Company` int(2) DEFAULT NULL, + `supplierAccountFk` mediumint(8) unsigned DEFAULT NULL, + `isDefaulter` tinyint(4) NOT NULL DEFAULT '0', + `companyGroupFk` int(11) NOT NULL DEFAULT '1' COMMENT 'usado para calcular los greuges ', + `companyCode` int(2) DEFAULT NULL COMMENT 'Campo para movConta', + `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', + `phytosanitary` longtext COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`), + KEY `gerente_id` (`workerManagerFk`), + KEY `empresa_cliente_idx` (`clientFk`), + KEY `Id_Proveedores_account` (`supplierAccountFk`), + KEY `empresa_grupo_fk_idx` (`companyGroupFk`), + CONSTRAINT `company_ibfk_1` FOREIGN KEY (`workerManagerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + CONSTRAINT `empresa_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `empresa_fk4` FOREIGN KEY (`supplierAccountFk`) REFERENCES `supplierAccount` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fk_empresa_grupo` FOREIGN KEY (`companyGroupFk`) REFERENCES `companyGroup` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `companyGroup` @@ -21183,6 +21759,28 @@ CREATE TABLE `companyGroup` ( ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `company__` +-- + +DROP TABLE IF EXISTS `company__`; +/*!50001 DROP VIEW IF EXISTS `company__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `company__` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `supplierAccountFk`, + 1 AS `workerManagerFk`, + 1 AS `sage200Company`, + 1 AS `footnotes`, + 1 AS `phytosanitary`, + 1 AS `companyCode`, + 1 AS `companyGroupFk`, + 1 AS `isDefaulter`, + 1 AS `expired`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `comparative` -- @@ -21349,14 +21947,118 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `country` +-- Table structure for table `country` -- DROP TABLE IF EXISTS `country`; -/*!50001 DROP VIEW IF EXISTS `country`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `country` ( + `Id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `country` varchar(25) COLLATE utf8_unicode_ci NOT NULL, + `CEE` tinyint(1) NOT NULL DEFAULT '1', + `code` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `politicalCountryFk` mediumint(8) unsigned NOT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', + `nstGeoFk` int(11) DEFAULT NULL, + `nstName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `geoFk` int(11) DEFAULT NULL, + `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT '0', + `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', + `ibanLength` tinyint(4) DEFAULT NULL, + PRIMARY KEY (`Id`), + KEY `Id_Paisreal` (`politicalCountryFk`) +) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!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`.`country_beforeInsert` + BEFORE INSERT ON `country` FOR EACH ROW +BEGIN + SET NEW.geoFk = zoneGeo_new('country', NEW.country, 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 `vn`.`country_beforeUpdate` + BEFORE UPDATE ON `country` 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`.`country_afterUpdate` AFTER UPDATE ON `country` FOR EACH ROW +BEGIN + IF !(OLD.country <=> NEW.country) THEN + UPDATE zoneGeo SET `name` = NEW.country + 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 `vn`.`country_afterDelete` AFTER DELETE ON `country` 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 `country__` +-- + +DROP TABLE IF EXISTS `country__`; +/*!50001 DROP VIEW IF EXISTS `country__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `country` AS SELECT +/*!50001 CREATE VIEW `country__` AS SELECT 1 AS `id`, 1 AS `country`, 1 AS `CEE`, @@ -21510,8 +22212,8 @@ CREATE TABLE `creditClassification` ( PRIMARY KEY (`id`), 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=3205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3238 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 */ ; @@ -21556,7 +22258,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=2931 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=3017 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 */ ; @@ -21648,14 +22350,30 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `deliveryMethod` +-- Table structure for table `deliveryMethod` -- DROP TABLE IF EXISTS `deliveryMethod`; -/*!50001 DROP VIEW IF EXISTS `deliveryMethod`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `deliveryMethod` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `deliveryMethod__` +-- + +DROP TABLE IF EXISTS `deliveryMethod__`; +/*!50001 DROP VIEW IF EXISTS `deliveryMethod__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `deliveryMethod` AS SELECT +/*!50001 CREATE VIEW `deliveryMethod__` AS SELECT 1 AS `id`, 1 AS `code`, 1 AS `description`*/; @@ -21683,7 +22401,9 @@ CREATE TABLE `delivery_zip` ( `accuracy` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, KEY `country_code_idx` (`country_code`), KEY `place_name_idx` (`place_name`), - KEY `postal_code_idx` (`postal_code`) + KEY `postal_code_idx` (`postal_code`), + KEY `admin_name3_idx` (`admin_name3`), + KEY `admin_name2_idx` (`admin_name2`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -21734,26 +22454,33 @@ 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=261 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=276 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `deviceProduction` +-- Table structure for table `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; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `deviceProduction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `imei` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `modelFk` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `macWifi` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `serialNumber` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `departmentFk` int(11) DEFAULT NULL, + `isOutOfService` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `device_id_UNIQUE` (`id`), + UNIQUE KEY `sn_UNIQUE` (`imei`), + KEY `deviceProductionModelsFgn` (`modelFk`), + KEY `departmentFgn` (`departmentFk`), + CONSTRAINT `departmentFgn` FOREIGN KEY (`departmentFk`) REFERENCES `vn2008`.`department` (`department_id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `deviceProductionModelsFgn` FOREIGN KEY (`modelFk`) REFERENCES `deviceProductionModels` (`code`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=344 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `deviceProductionModels` @@ -21769,18 +22496,53 @@ CREATE TABLE `deviceProductionModels` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `deviceProductionUser` +-- Table structure for table `deviceProductionUser` -- DROP TABLE IF EXISTS `deviceProductionUser`; -/*!50001 DROP VIEW IF EXISTS `deviceProductionUser`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `deviceProductionUser` ( + `deviceProductionFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`deviceProductionFk`,`userFk`), + KEY `userFgn_idx` (`userFk`), + CONSTRAINT `deviceProductionFgn` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `userFgn` 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 */; + +-- +-- 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 +/*!50001 CREATE VIEW `deviceProductionUser__` AS SELECT 1 AS `deviceProductionFk`, 1 AS `userFk`*/; 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 `departmentFk`, + 1 AS `serialNumber`, + 1 AS `modelFk`, + 1 AS `isOutOfService`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `dms` -- @@ -21805,14 +22567,36 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `dmsType` +-- Table structure for table `dmsType` -- DROP TABLE IF EXISTS `dmsType`; -/*!50001 DROP VIEW IF EXISTS `dmsType`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `dmsType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `path` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `writeRoleFk` int(10) unsigned DEFAULT NULL, + `readRoleFk` int(10) unsigned DEFAULT NULL, + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `readRoleFk` (`readRoleFk`), + KEY `writeRoleFk` (`writeRoleFk`), + CONSTRAINT `readRoleFk` FOREIGN KEY (`readRoleFk`) REFERENCES `account`.`role` (`id`), + CONSTRAINT `writeRoleFk` FOREIGN KEY (`writeRoleFk`) REFERENCES `account`.`role` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `dmsType__` +-- + +DROP TABLE IF EXISTS `dmsType__`; +/*!50001 DROP VIEW IF EXISTS `dmsType__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `dmsType` AS SELECT +/*!50001 CREATE VIEW `dmsType__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `path`, @@ -21867,8 +22651,8 @@ CREATE TABLE `dua` ( KEY `dua_fk4_idx` (`companyFk`), CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4129 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21907,9 +22691,9 @@ CREATE TABLE `duaIntrastat` ( PRIMARY KEY (`id`), KEY `duaIntrastat_fk1_idx` (`intrastatFk`), KEY `duaIntrastat_fk2_idx` (`duaFk`), - CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `vn2008`.`Intrastat` (`Codintrastat`) ON UPDATE CASCADE, + CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6684 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21929,7 +22713,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=5045 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=5119 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 */; -- @@ -21952,9 +22736,9 @@ CREATE TABLE `duaTax` ( KEY `duaTax_fk2_idx` (`supplierFk`), KEY `duaTax_fk3_idx` (`taxClassFk`), CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, - CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, + CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=9165 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22087,10 +22871,10 @@ CREATE TABLE `entry` ( KEY `gestdoc_id` (`gestDocFk`), KEY `recibida_id` (`invoiceInFk`), CONSTRAINT `Entradas_fk8` FOREIGN KEY (`invoiceInFk`) REFERENCES `vn2008`.`recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, + CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, - CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=176725 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; + CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=179070 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 */ ; @@ -22291,7 +23075,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=162003 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=168919 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22342,7 +23126,7 @@ CREATE TABLE `envialiaCity` ( PRIMARY KEY (`id`), KEY `agencyFk` (`agencyFk`), KEY `postalCode` (`postalCode`) -) ENGINE=InnoDB AUTO_INCREMENT=1383316 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1423686 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22512,25 +23296,128 @@ CREATE TABLE `excuse` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `expedition` +-- Table structure for table `expedition` -- DROP TABLE IF EXISTS `expedition`; -/*!50001 DROP VIEW IF EXISTS `expedition`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expedition` AS SELECT - 1 AS `id`, - 1 AS `agencyModeFk`, - 1 AS `ticketFk`, - 1 AS `isBox`, - 1 AS `created`, - 1 AS `itemFk`, - 1 AS `counter`, - 1 AS `checked`, - 1 AS `workerFk`, - 1 AS `externalId`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `expedition` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `agencyModeFk` int(11) NOT NULL, + `ticketFk` int(10) NOT NULL, + `isBox` int(11) DEFAULT '1', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isRefund` bit(1) DEFAULT b'0', + `isPickUp` bit(1) DEFAULT b'0', + `itemFk` int(11) DEFAULT NULL, + `counter` smallint(5) unsigned NOT NULL, + `checked` tinyint(4) NOT NULL DEFAULT '0', + `workerFk` int(11) DEFAULT NULL, + `externalId` bigint(25) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `index1` (`agencyModeFk`), + KEY `index2` (`isBox`), + KEY `index3` (`created`), + KEY `index4` (`ticketFk`), + CONSTRAINT `Id_Agencia` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3322463 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`.`expedition_beforeInsert` + BEFORE INSERT ON `expedition` FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN + DECLARE intcounter INT; + DECLARE vShipFk INT; + + IF NEW.isBox > 0 THEN + + UPDATE ticket SET packages = nz(packages) + 1 WHERE id = NEW.ticketFk; + + SELECT IFNULL(MAX(counter),0) +1 INTO intcounter + FROM expedition e + INNER JOIN ticket t1 ON e.ticketFk = t1.id + LEFT JOIN ticketState ts ON ts.ticket = t1.id + INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + AND t1.warehouseFk = t2.warehouseFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + AND t1.agencyModeFk = t2.agencyModeFk; + + SET NEW.`counter` = intcounter; + END IF; + + -- JGF 14/01/19 si existe un polizon queda anulado + SELECT shipFk INTO vShipFk FROM stowaway WHERE id = NEW.ticketFk; + + IF vShipFk THEN + CALL stowawayUnBoarding(vShipFk, NEW.ticketFk); + 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`.`expedition_beforeUpdate` + BEFORE UPDATE ON `expedition` FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN + IF NEW.counter <> OLD.counter THEN + IF (SELECT COUNT(*) FROM expedition e + INNER JOIN ticket t1 ON e.ticketFk = t1.id + INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + WHERE t1.id = NEW.ticketFk AND counter = NEW.counter) > 0 THEN + SET NEW.id = NULL; + END IF; + 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`.`expedition_beforeDelete` + BEFORE DELETE ON `expedition` FOR EACH ROW +BEGIN + UPDATE ticket t + SET packages = (SELECT COUNT(counter)-1 + FROM expedition e WHERE e.ticketFk = OLD.ticketFk and e.isBox) + WHERE t.id = OLD.ticketFk; + +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 `expeditionBoxVol` @@ -22548,14 +23435,54 @@ CREATE TABLE `expeditionBoxVol` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `expence` +-- Temporary table structure for view `expedition__` +-- + +DROP TABLE IF EXISTS `expedition__`; +/*!50001 DROP VIEW IF EXISTS `expedition__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `expedition__` AS SELECT + 1 AS `id`, + 1 AS `agencyModeFk`, + 1 AS `ticketFk`, + 1 AS `isBox`, + 1 AS `created`, + 1 AS `itemFk`, + 1 AS `counter`, + 1 AS `checked`, + 1 AS `workerFk`, + 1 AS `externalId`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `expence` -- DROP TABLE IF EXISTS `expence`; -/*!50001 DROP VIEW IF EXISTS `expence`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `expence` ( + `id` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `taxTypeFk` tinyint(4) NOT NULL, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `isConbase` tinyint(4) NOT NULL DEFAULT '1', + `isWithheld` tinyint(4) NOT NULL DEFAULT '0', + `isForSale` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`,`taxTypeFk`), + KEY `iva_tipo_id` (`taxTypeFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `expence__` +-- + +DROP TABLE IF EXISTS `expence__`; +/*!50001 DROP VIEW IF EXISTS `expence__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `expence` AS SELECT +/*!50001 CREATE VIEW `expence__` AS SELECT 1 AS `id`, 1 AS `taxTypeFk`, 1 AS `name`, @@ -22671,9 +23598,9 @@ CREATE TABLE `greuge` ( 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 `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3650147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; +) ENGINE=InnoDB AUTO_INCREMENT=3719157 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 */ ; @@ -22800,19 +23727,22 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `ink` +-- Table structure for table `ink` -- DROP TABLE IF EXISTS `ink`; -/*!50001 DROP VIEW IF EXISTS `ink`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `ink` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `picture`, - 1 AS `showOrder`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ink` ( + `id` char(3) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `picture` blob NOT NULL, + `showOrder` int(11) NOT NULL, + `ball` blob, + `isCargex` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `inkI18n` @@ -22843,14 +23773,50 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `intrastat` +-- Temporary table structure for view `ink__` +-- + +DROP TABLE IF EXISTS `ink__`; +/*!50001 DROP VIEW IF EXISTS `ink__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ink__` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `picture`, + 1 AS `showOrder`, + 1 AS `ball`, + 1 AS `isCargex`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `intrastat` -- DROP TABLE IF EXISTS `intrastat`; -/*!50001 DROP VIEW IF EXISTS `intrastat`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `intrastat` ( + `id` int(8) unsigned zerofill NOT NULL, + `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `import` tinyint(4) NOT NULL DEFAULT '0', + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + `taxCodeFk` tinyint(2) unsigned NOT NULL DEFAULT '64', + PRIMARY KEY (`id`), + KEY `iva_group_id` (`taxClassFk`), + CONSTRAINT `intrastat_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `intrastat__` +-- + +DROP TABLE IF EXISTS `intrastat__`; +/*!50001 DROP VIEW IF EXISTS `intrastat__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `intrastat` AS SELECT +/*!50001 CREATE VIEW `intrastat__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `taxClassFk`, @@ -22881,12 +23847,12 @@ CREATE TABLE `inventoryFailure` ( KEY `inventoryFailure_fk_idx` (`guiltyFk`), KEY `inventoryFailure_fk4_idx` (`warehouseFk`), KEY `inventoryFailure_fk5_idx` (`causeFk`), - CONSTRAINT `inventoryFailure_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `inventoryFailure_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk2` FOREIGN KEY (`throwerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, 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=19742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22714 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23106,37 +24072,170 @@ CREATE TABLE `invoiceInTaxBookingAccount` ( KEY `invoiceInTaxBookingAccount_fk2_idx` (`taxClassFk`), KEY `invoiceInTaxBookingAccount_fk3_idx` (`countryFk`), CONSTRAINT `invoiceInTaxBookingAccount_fk1` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `invoiceInTaxBookingAccount_fk2` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE, - CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE + CONSTRAINT `invoiceInTaxBookingAccount_fk2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `invoiceOut` +-- Table structure for table `invoiceOut` -- DROP TABLE IF EXISTS `invoiceOut`; -/*!50001 DROP VIEW IF EXISTS `invoiceOut`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `invoiceOut` AS SELECT - 1 AS `id`, - 1 AS `ref`, - 1 AS `serial`, - 1 AS `issued`, - 1 AS `amount`, - 1 AS `clientFk`, - 1 AS `created`, - 1 AS `companyFk`, - 1 AS `dued`, - 1 AS `booked`, - 1 AS `bankFk`, - 1 AS `cplusInvoiceType477Fk`, - 1 AS `cplusTaxBreakFk`, - 1 AS `cplusSubjectOpFk`, - 1 AS `cplusTrascendency477Fk`, - 1 AS `hasPdf`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `invoiceOut` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `ref` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `serial` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `issued` date DEFAULT NULL, + `amount` decimal(12,2) DEFAULT '0.00', + `dued` datetime DEFAULT NULL, + `bankFk` int(11) DEFAULT NULL, + `clientFk` int(11) DEFAULT '0', + `Id_Remesa__` int(11) DEFAULT NULL, + `Remesar__` tinyint(1) NOT NULL DEFAULT '0', + `taxableBase7` decimal(12,2) DEFAULT '0.00', + `taxableBase16` decimal(12,2) DEFAULT '0.00', + `equ1` decimal(12,2) DEFAULT '0.00', + `equ4` decimal(12,2) DEFAULT '0.00', + `vat7` decimal(12,2) DEFAULT '0.00', + `vat16` decimal(12,2) DEFAULT '0.00', + `workerFk` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `liquidacion__` smallint(6) DEFAULT '0', + `hasPdf` tinyint(3) unsigned NOT NULL DEFAULT '0', + `booked` date DEFAULT NULL, + `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT '1', + `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`,`ref`), + UNIQUE KEY `Id_Factura` (`ref`), + KEY `Id_Banco` (`bankFk`), + KEY `Id_Cliente` (`clientFk`), + KEY `Id_Remesa` (`Id_Remesa__`), + KEY `Id_Trabajador` (`workerFk`), + KEY `empresa_id` (`companyFk`), + KEY `Fecha` (`issued`), + KEY `Facturas_ibfk_2_idx` (`cplusInvoiceType477Fk`), + KEY `Facturas_ibfk_3_idx` (`cplusSubjectOpFk`), + KEY `Facturas_ibfk_4_idx` (`cplusTaxBreakFk`), + KEY `Facturas_ibfk_5_idx` (`cplusTrascendency477Fk`), + KEY `Facturas_idx_Vencimiento` (`dued`), + CONSTRAINT `invoiceOut_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceOut_ibfk_2` FOREIGN KEY (`cplusInvoiceType477Fk`) REFERENCES `cplusInvoiceType477` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceOut_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=517213 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`.`invoiceOut_beforeInsert` + BEFORE INSERT ON `invoiceOut` FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN + DECLARE vRef CHAR(9) DEFAULT '0000001'; + DECLARE vMaxId INT; + + SELECT IFNULL(MAX(id),0) INTO vMaxId + FROM invoiceOut + WHERE serial LIKE NEW.serial + AND ((Year(NEW.issued) = Year(issued) + AND companyFk = NEW.companyFk)); + + IF vMaxId THEN + + SELECT RIGHT(MAX(ref), LENGTH(ref)-1) + 1 + INTO vRef + FROM invoiceOut + WHERE serial LIKE NEW.serial + AND ((Year(NEW.issued) = Year(issued) + AND length(ref) > 6 + AND companyFk = NEW.companyFk) /*OR (NEW.serial LIKE 'B' AND length(ref) > 7)*/ ); + ELSE + SELECT CONCAT(sage200Company,RIGHT(YEAR(CURDATE()),1),'00001') INTO vRef + FROM company + WHERE id = NEW.companyFk; +/*Primer digito la empresa, segundo el año, despues la numeracion correlativa con 5 digitos*/ + END IF; + + SELECT CONCAT(NEW.serial, LPAD(vRef,7,'0')) INTO vRef; + SET NEW.ref = vRef; +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`.`invoiceOut_afterInsert` + AFTER INSERT ON `invoiceOut` FOR EACH ROW +BEGIN + CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, NEW.amount); +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`.`invoiceOut_beforeUpdate` + BEFORE UPDATE ON `invoiceOut` FOR EACH ROW +BEGIN + CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); + CALL bi.customer_risk_update (NEW.clientFk, NEW.companyFk, NEW.amount); +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`.`invoiceOut_beforeDelete` + BEFORE DELETE ON `invoiceOut` FOR EACH ROW +BEGIN + CALL bi.customer_risk_update (OLD.clientFk, OLD.companyFk, -OLD.amount); +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 `invoiceOutExpence` @@ -23155,9 +24254,9 @@ CREATE TABLE `invoiceOutExpence` ( UNIQUE KEY `invoiceOutExpence_restriccion` (`expenceFk`,`invoiceOutFk`), KEY `invoiceOutExpence_FK_1_idx` (`invoiceOutFk`), 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=126986 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; + CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=131089 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 */; -- @@ -23198,92 +24297,347 @@ CREATE TABLE `invoiceOutTax` ( UNIQUE KEY `invoiceOutTax_Resctriccion` (`invoiceOutFk`,`pgcFk`), KEY `invoiceOutFk_idx` (`invoiceOutFk`), KEY `pgcFk` (`pgcFk`), - CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1144269 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1160150 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `item` +-- Temporary table structure for view `invoiceOut__` -- -DROP TABLE IF EXISTS `item`; -/*!50001 DROP VIEW IF EXISTS `item`*/; +DROP TABLE IF EXISTS `invoiceOut__`; +/*!50001 DROP VIEW IF EXISTS `invoiceOut__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `item` AS SELECT +/*!50001 CREATE VIEW `invoiceOut__` AS SELECT 1 AS `id`, - 1 AS `name`, - 1 AS `typeFk`, - 1 AS `size`, - 1 AS `inkFk`, - 1 AS `category`, - 1 AS `stems`, - 1 AS `originFk`, - 1 AS `description`, - 1 AS `producerFk`, - 1 AS `intrastatFk`, - 1 AS `isOnOffer`, - 1 AS `box`, - 1 AS `expenceFk`, - 1 AS `isBargain`, - 1 AS `comment`, - 1 AS `relevancy`, - 1 AS `image`, - 1 AS `generic`, - 1 AS `density`, - 1 AS `taxClassFk`, - 1 AS `minPrice`, - 1 AS `hasMinPrice`, - 1 AS `isActive`, - 1 AS `longName`, - 1 AS `subName`, - 1 AS `tag5`, - 1 AS `value5`, - 1 AS `tag6`, - 1 AS `value6`, - 1 AS `tag7`, - 1 AS `value7`, - 1 AS `tag8`, - 1 AS `value8`, - 1 AS `tag9`, - 1 AS `value9`, - 1 AS `tag10`, - 1 AS `value10`, - 1 AS `minimum`, - 1 AS `upToDown`, - 1 AS `compression`, - 1 AS `hasKgPrice`*/; + 1 AS `ref`, + 1 AS `serial`, + 1 AS `issued`, + 1 AS `amount`, + 1 AS `clientFk`, + 1 AS `created`, + 1 AS `companyFk`, + 1 AS `dued`, + 1 AS `booked`, + 1 AS `bankFk`, + 1 AS `cplusInvoiceType477Fk`, + 1 AS `cplusTaxBreakFk`, + 1 AS `cplusSubjectOpFk`, + 1 AS `cplusTrascendency477Fk`, + 1 AS `hasPdf`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemBarcode` +-- Table structure for table `item` +-- + +DROP TABLE IF EXISTS `item`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `item` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `equivalent` int(11) unsigned DEFAULT NULL, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `size` int(10) unsigned DEFAULT NULL, + `stems` int(11) DEFAULT '1', + `minPrice` double DEFAULT '0', + `isToPrint` tinyint(1) NOT NULL DEFAULT '0', + `isDeliveryNote` tinyint(1) NOT NULL DEFAULT '0', + `taxClassFk` tinyint(4) unsigned NOT NULL DEFAULT '1', + `family` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'VT', + `box` tinyint(1) NOT NULL DEFAULT '0', + `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `originFk` tinyint(2) unsigned NOT NULL, + `doPhoto` tinyint(4) NOT NULL DEFAULT '0', + `image` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `intrastatFk` int(8) unsigned zerofill DEFAULT NULL, + `hasMinPrice` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isOnOffer` tinyint(4) NOT NULL DEFAULT '0', + `isBargain` tinyint(4) NOT NULL DEFAULT '0', + `comment` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `typeFk` smallint(5) unsigned NOT NULL, + `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `density` int(11) NOT NULL DEFAULT '167' COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', + `relevancy` tinyint(1) NOT NULL DEFAULT '0', + `expenceFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '7001000000', + `isActive` tinyint(1) NOT NULL DEFAULT '1', + `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `subName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag6` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value6` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `value9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `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' COMMENT 'Se muestra el precio por kilo ', + `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', + `sectorFk` int(11) DEFAULT '2', + PRIMARY KEY (`id`), + KEY `Article` (`name`), + KEY `Color` (`inkFk`), + KEY `id_origen` (`originFk`), + KEY `Codintrastat` (`intrastatFk`), + KEY `iva_group_id` (`taxClassFk`), + KEY `tipo_id` (`typeFk`), + KEY `producer_id` (`producerFk`), + KEY `expenceFk_idx` (`expenceFk`), + KEY `ArticlesIsActive_idx` (`isActive`), + KEY `item_ibfk_6_idx` (`sectorFk`), + CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `origin` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_4` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=370493 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`.`item_beforeInsert` + BEFORE INSERT ON `item` FOR EACH ROW +BEGIN + DECLARE vDensity DOUBLE; + DECLARE vInsertId INT; + DECLARE vProducerFk VARCHAR(50); + DECLARE vInkName VARCHAR(50); + + IF NEW.density IS NULL THEN + SELECT density INTO vDensity + FROM itemType WHERE id = NEW.typeFk; + + SET NEW.density = vDensity; + END IF; + + -- Migration +/* + SET NEW.longName = NEW.Article; + + IF NEW.producerFk is not null THEN + SELECT name INTO vProducerFk FROM producer WHERE id = NEW.producerFk; + SET NEW.subname = vProducerFk; + END IF; + + IF NEW.size IS NOT NULL AND NEW.value5 IS NULL THEN + SET NEW.tag5 ='Medida'; + SET NEW.value5 = NEW.size; + END IF; + + IF NEW.inkFk IS NOT NULL AND NEW.value6 IS NULL THEN + SET NEW.tag6 ='Color'; + SELECT name INTO vInkName FROM vn.ink i where i.id = NEW.inkFk; + SET NEW.value6 = vInkName; + END IF; + + IF NEW.category IS NOT NULL AND NEW.value7 IS NULL THEN + SET NEW.tag7 ='Categoria'; + SET NEW.value7 = NEW.category; + END IF; + + IF NEW.stems IS NOT NULL AND NEW.value8 IS NULL THEN + SET NEW.tag8 ='Tallos'; + SET NEW.value8 = NEW.stems; + 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`.`item_afterInsert` + AFTER INSERT ON `item` FOR EACH ROW +BEGIN + CALL hedera.image_ref('catalog', NEW.image); + + INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) + SELECT NEW.id, 1, NEW.taxClassFk; + + INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) + SELECT NEW.id, 5, NEW.taxClassFk; + + INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) + SELECT NEW.id, 30, NEW.taxClassFk; +/* + IF NEW.typeFk IS NOT NULL THEN + INSERT INTO vn.itemTag (itemFk, tagFk, priority) + SELECT NEW.id, tagFk, priority FROM vn.itemTypeTag + WHERE itemTypeFk = NEW.typeFk; + 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`.`item_afterUpdate` + AFTER UPDATE ON `item` FOR EACH ROW +BEGIN + IF !(NEW.image <=> OLD.image) THEN + CALL hedera.image_unref('catalog', OLD.image); + CALL hedera.image_ref('catalog', NEW.image); + 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`.`item_afterDelete` + AFTER DELETE ON `item` FOR EACH ROW +BEGIN + CALL hedera.image_unref('catalog', OLD.image); + +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 `itemBarcode` -- DROP TABLE IF EXISTS `itemBarcode`; -/*!50001 DROP VIEW IF EXISTS `itemBarcode`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemBarcode` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `code` varchar(22) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`), + UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), + KEY `Id_Article` (`itemFk`), + CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=42076 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `itemBarcode__` +-- + +DROP TABLE IF EXISTS `itemBarcode__`; +/*!50001 DROP VIEW IF EXISTS `itemBarcode__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemBarcode` AS SELECT +/*!50001 CREATE VIEW `itemBarcode__` AS SELECT 1 AS `id`, 1 AS `itemFk`, 1 AS `code`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemBotanical` +-- Table structure for table `itemBotanical` -- DROP TABLE IF EXISTS `itemBotanical`; -/*!50001 DROP VIEW IF EXISTS `itemBotanical`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemBotanical` AS SELECT - 1 AS `itemFk`, - 1 AS `botanical`, - 1 AS `genusFk`, - 1 AS `specieFk`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemBotanical` ( + `itemFk` int(11) NOT NULL, + `botanical` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `genusFk` mediumint(8) unsigned DEFAULT NULL, + `specieFk` mediumint(8) unsigned DEFAULT NULL, + PRIMARY KEY (`itemFk`), + KEY `genusFgn_idx` (`genusFk`), + KEY `specieFgn_idx` (`specieFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; +/*!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`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW +BEGIN + IF NEW.botanical = '' THEN + SET NEW.botanical = NULL; + END IF; + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!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`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW +BEGIN + IF NEW.botanical = '' THEN + SET NEW.botanical = NULL; + END IF; + +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `itemBotanicalWithGenus` @@ -23298,6 +24652,21 @@ SET character_set_client = utf8; 1 AS `ediBotanic`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `itemBotanical__` +-- + +DROP TABLE IF EXISTS `itemBotanical__`; +/*!50001 DROP VIEW IF EXISTS `itemBotanical__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemBotanical__` AS SELECT + 1 AS `itemFk`, + 1 AS `botanical`, + 1 AS `genusFk`, + 1 AS `specieFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `itemCategory` -- @@ -23347,6 +24716,25 @@ SET character_set_client = utf8; 1 AS `name`*/; 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; + -- -- Table structure for table `itemConversor` -- @@ -23359,8 +24747,8 @@ CREATE TABLE `itemConversor` ( `genItemFk` int(11) DEFAULT NULL, PRIMARY KEY (`espItemFk`), KEY `itemConversor_fk2_idx` (`genItemFk`), - CONSTRAINT `itemConversor_fk1` FOREIGN KEY (`espItemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemConversor_fk2` FOREIGN KEY (`genItemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `itemConversor_fk1` FOREIGN KEY (`espItemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemConversor_fk2` FOREIGN KEY (`genItemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona los item específicos con los genéricos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23399,28 +24787,33 @@ CREATE TABLE `itemLog` ( PRIMARY KEY (`id`), KEY `itemLogItemFk_idx` (`originFk`), KEY `itemLogUserFk_idx` (`userFk`), - CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65272 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=79534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `itemPlacement` +-- Table structure for table `itemPlacement` -- DROP TABLE IF EXISTS `itemPlacement`; -/*!50001 DROP VIEW IF EXISTS `itemPlacement`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemPlacement` AS SELECT - 1 AS `id`, - 1 AS `itemFk`, - 1 AS `warehouseFk`, - 1 AS `code`, - 1 AS `reserve`, - 1 AS `pickable`, - 1 AS `modificationDate`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemPlacement` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `code` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `pickable` int(11) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `Id_Article_UNIQUE` (`itemFk`,`warehouseFk`), + KEY `Articles_nicho_wh_fk` (`warehouseFk`), + CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=923937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `itemPlacementSupply` @@ -23441,10 +24834,10 @@ CREATE TABLE `itemPlacementSupply` ( KEY `itemPlacementSupply_fk1_idx` (`itemFk`), KEY `itemPlacementSupply_fk2_idx` (`userFk`), KEY `itemPlacementSupply_fk2_idx1` (`repoUserFk`), - CONSTRAINT `itemPlacementSupply_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemPlacementSupply_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) 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=53941 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=66694 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 */; -- @@ -23474,28 +24867,21 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemPlacementSupplyList__` +-- Temporary table structure for view `itemPlacement__` -- -DROP TABLE IF EXISTS `itemPlacementSupplyList__`; -/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +DROP TABLE IF EXISTS `itemPlacement__`; +/*!50001 DROP VIEW IF EXISTS `itemPlacement__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemPlacementSupplyList__` AS SELECT +/*!50001 CREATE VIEW `itemPlacement__` 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 `warehouseFk`, + 1 AS `code`, + 1 AS `reserve`, + 1 AS `pickable`, + 1 AS `modificationDate`*/; SET character_set_client = @saved_cs_client; -- @@ -23509,7 +24895,7 @@ CREATE TABLE `itemRepo` ( `itemFk` int(11) NOT NULL, `quantity` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`itemFk`), - CONSTRAINT `itemRepo_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `itemRepo_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23539,10 +24925,10 @@ CREATE TABLE `itemShelving` ( KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), KEY `itemShelving_fk3_idx` (`packagingFk`), - CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) 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 '; + CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=122994 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 */; -- @@ -23574,7 +24960,8 @@ SET character_set_client = utf8; 1 AS `grouping`, 1 AS `packing`, 1 AS `hour`, - 1 AS `isPreviousPreparable`*/; + 1 AS `isPreviousPreparable`, + 1 AS `physicalVolume`*/; SET character_set_client = @saved_cs_client; -- @@ -23618,7 +25005,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=50804 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB AUTO_INCREMENT=63490 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 */; -- @@ -23663,10 +25050,32 @@ CREATE TABLE `itemShelvingSale` ( KEY `itemShelvingSale_fk2_idx` (`saleFk`), KEY `itemShelvingSale_fk3_idx` (`userFk`), 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_fk2` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) 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'; +) ENGINE=InnoDB AUTO_INCREMENT=27331 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!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`.`itemShelvingSale_AFTER_INSERT` AFTER INSERT ON `itemShelvingSale` FOR EACH ROW +BEGIN + + UPDATE vn.sale + SET isPicked = TRUE + WHERE id = NEW.saleFk; + +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 `itemShelvingSaleSum` @@ -23681,7 +25090,8 @@ SET character_set_client = utf8; 1 AS `itemShelvingFk`, 1 AS `saleFk`, 1 AS `quantity`, - 1 AS `created`*/; + 1 AS `created`, + 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; -- @@ -23696,11 +25106,41 @@ SET character_set_client = utf8; 1 AS `itemFk`, 1 AS `visible`, 1 AS `packing`, + 1 AS `grouping`, 1 AS `sector`, 1 AS `visibleOriginal`, 1 AS `removed`, 1 AS `sectorFk`, - 1 AS `warehouseFk`*/; + 1 AS `warehouseFk`, + 1 AS `shelvingFk`, + 1 AS `parkingCode`, + 1 AS `parkingFk`, + 1 AS `itemShelvingFk`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `itemShelvingStockFull` +-- + +DROP TABLE IF EXISTS `itemShelvingStockFull`; +/*!50001 DROP VIEW IF EXISTS `itemShelvingStockFull`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemShelvingStockFull` AS SELECT + 1 AS `itemFk`, + 1 AS `quantity`, + 1 AS `packing`, + 1 AS `grouping`, + 1 AS `sector`, + 1 AS `removed`, + 1 AS `sectorFk`, + 1 AS `warehouseFk`, + 1 AS `shelvingFk`, + 1 AS `parkingCode`, + 1 AS `parkingFk`, + 1 AS `itemShelvingFk`, + 1 AS `created`*/; SET character_set_client = @saved_cs_client; -- @@ -23717,23 +25157,6 @@ SET character_set_client = utf8; 1 AS `removed`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `itemShelvingStock__` --- - -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__` AS SELECT - 1 AS `itemFk`, - 1 AS `visible`, - 1 AS `packing`, - 1 AS `sector`, - 1 AS `visibleOriginal`, - 1 AS `removed`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `itemTag` -- @@ -23754,9 +25177,9 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`priority`,`itemFk`), KEY `value` (`value`), KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), - CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1307755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1351662 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 */ ; @@ -23898,10 +25321,10 @@ CREATE TABLE `itemTaxCountry` ( KEY `taxClassFK_idx` (`taxClassFk`), KEY `countryFK_paises_idx` (`countryFk`), KEY `itemFK_Article_idx` (`itemFk`), - 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=820488 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; + CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=848655 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 */; -- @@ -23976,7 +25399,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemType_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `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.'; +) ENGINE=InnoDB AUTO_INCREMENT=281 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 */ ; @@ -24056,9 +25479,48 @@ CREATE TABLE `itemTypeTag` ( 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 `itemType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=250 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 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; + -- -- Table structure for table `itemVerdecora` -- @@ -24070,10 +25532,70 @@ CREATE TABLE `itemVerdecora` ( `itemFk` int(11) NOT NULL, `codin` int(11) DEFAULT NULL, PRIMARY KEY (`itemFk`), - CONSTRAINT `itemVerdecora_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `itemVerdecora_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona nuestros articulos con los de Verdecora'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `item__` +-- + +DROP TABLE IF EXISTS `item__`; +/*!50001 DROP VIEW IF EXISTS `item__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `item__` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `typeFk`, + 1 AS `size`, + 1 AS `inkFk`, + 1 AS `category`, + 1 AS `stems`, + 1 AS `originFk`, + 1 AS `description`, + 1 AS `producerFk`, + 1 AS `intrastatFk`, + 1 AS `isOnOffer`, + 1 AS `box`, + 1 AS `expenceFk`, + 1 AS `isBargain`, + 1 AS `comment`, + 1 AS `relevancy`, + 1 AS `image`, + 1 AS `generic`, + 1 AS `density`, + 1 AS `taxClassFk`, + 1 AS `minPrice`, + 1 AS `hasMinPrice`, + 1 AS `isActive`, + 1 AS `longName`, + 1 AS `subName`, + 1 AS `tag5`, + 1 AS `value5`, + 1 AS `tag6`, + 1 AS `value6`, + 1 AS `tag7`, + 1 AS `value7`, + 1 AS `tag8`, + 1 AS `value8`, + 1 AS `tag9`, + 1 AS `value9`, + 1 AS `tag10`, + 1 AS `value10`, + 1 AS `minimum`, + 1 AS `upToDown`, + 1 AS `compression`, + 1 AS `hasKgPrice`, + 1 AS `equivalent`, + 1 AS `isToPrint`, + 1 AS `isDeliveryNote`, + 1 AS `family`, + 1 AS `doPhoto`, + 1 AS `niche`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `labourTree` -- @@ -24168,10 +25690,10 @@ CREATE TABLE `mandate` ( 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_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`mandateTypeFk`) REFERENCES `mandateType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16862 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=17123 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 */ ; @@ -24296,7 +25818,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=304 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=366 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24317,7 +25839,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1961608 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1996780 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24339,7 +25861,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2133578 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2170346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24409,32 +25931,68 @@ CREATE TABLE `observationType` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `orderTicket` +-- 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; + +-- +-- Table structure for table `orderTicket` -- DROP TABLE IF EXISTS `orderTicket`; -/*!50001 DROP VIEW IF EXISTS `orderTicket`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `orderTicket` ( + `orderFk` int(10) unsigned NOT NULL, + `ticketFk` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`ticketFk`,`orderFk`), + KEY `order_id` (`orderFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `orderTicket__` +-- + +DROP TABLE IF EXISTS `orderTicket__`; +/*!50001 DROP VIEW IF EXISTS `orderTicket__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `orderTicket` AS SELECT +/*!50001 CREATE VIEW `orderTicket__` AS SELECT 1 AS `orderFk`, 1 AS `ticketFk`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `origin` +-- Table structure for table `origin` -- DROP TABLE IF EXISTS `origin`; -/*!50001 DROP VIEW IF EXISTS `origin`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `origin` AS SELECT - 1 AS `id`, - 1 AS `code`, - 1 AS `name`, - 1 AS `countryFk`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `origin` ( + `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, + `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT '4', + `flag` blob, + `nl` tinyint(4) NOT NULL DEFAULT '0', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `Abreviatura` (`code`), + KEY `warehouse_id` (`warehouseFk`), + KEY `Id_Paises` (`countryFk`), + CONSTRAINT `origin_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `originI18n` @@ -24464,6 +26022,21 @@ SET character_set_client = utf8; 1 AS `name`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `origin__` +-- + +DROP TABLE IF EXISTS `origin__`; +/*!50001 DROP VIEW IF EXISTS `origin__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `origin__` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `name`, + 1 AS `countryFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `outgoingInvoiceKk` -- @@ -24518,7 +26091,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1675 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2624 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24533,8 +26106,8 @@ CREATE TABLE `packageEquivalent` ( `equivalentFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`packageFk`,`equivalentFk`), KEY `packageEquivalent_fk2_idx` (`equivalentFk`), - CONSTRAINT `packageEquivalent_fk1` FOREIGN KEY (`packageFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `packageEquivalent_fk2` FOREIGN KEY (`equivalentFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `packageEquivalent_fk1` FOREIGN KEY (`packageFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `packageEquivalent_fk2` FOREIGN KEY (`equivalentFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='recoge los modelos de cubos que se han de sustituir a efectos de presentar informes resumidos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -24552,14 +26125,45 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `packaging` +-- Table structure for table `packaging` -- DROP TABLE IF EXISTS `packaging`; -/*!50001 DROP VIEW IF EXISTS `packaging`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `packaging` ( + `id` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `volume` decimal(10,2) DEFAULT '0.00', + `width` decimal(10,2) DEFAULT '0.00', + `depth` decimal(10,2) DEFAULT '0.00', + `height` decimal(10,2) DEFAULT '0.00', + `value` decimal(10,2) DEFAULT '0.00', + `isPackageReturnable` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `packagingReturnFk` int(11) DEFAULT NULL, + `lower` int(11) DEFAULT NULL, + `upload` int(11) DEFAULT NULL, + `base` decimal(10,2) DEFAULT NULL, + `itemFk` int(11) DEFAULT NULL, + `price` decimal(10,2) NOT NULL, + `isBox` tinyint(1) NOT NULL DEFAULT '0', + `cubicPackage` decimal(10,2) DEFAULT NULL, + `returnCost` decimal(10,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id`), + KEY `Article` (`itemFk`), + CONSTRAINT `Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `packaging__` +-- + +DROP TABLE IF EXISTS `packaging__`; +/*!50001 DROP VIEW IF EXISTS `packaging__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `packaging` AS SELECT +/*!50001 CREATE VIEW `packaging__` AS SELECT 1 AS `id`, 1 AS `volume`, 1 AS `width`, @@ -24590,7 +26194,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=26175 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=26462 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 */ ; @@ -24634,14 +26238,28 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Temporary table structure for view `payDem` +-- Table structure for table `payDem` -- DROP TABLE IF EXISTS `payDem`; -/*!50001 DROP VIEW IF EXISTS `payDem`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `payDem` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `payDem` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `payDem__` +-- + +DROP TABLE IF EXISTS `payDem__`; +/*!50001 DROP VIEW IF EXISTS `payDem__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `payDem` AS SELECT +/*!50001 CREATE VIEW `payDem__` AS SELECT 1 AS `id`, 1 AS `payDem`*/; SET character_set_client = @saved_cs_client; @@ -24875,12 +26493,8 @@ 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); + SET NEW.geoFk = zoneGeo_new('postCode', NEW.`code`, + (SELECT geoFk FROM town WHERE id = NEW.townFk)); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24890,18 +26504,18 @@ 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 `vn`.`postCode_beforeUpdate` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `postCode_beforeUpdate` BEFORE UPDATE ON `postCode` FOR EACH ROW BEGIN - -- IF !(OLD.geoFk <=> NEW.geoFk) THEN - -- CALL zoneGeo_check; - -- END IF; + IF !(OLD.geoFk <=> NEW.geoFk) THEN + CALL zoneGeo_throwNotEditable; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24920,19 +26534,15 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`postCode_afterUpdate` AFTER UPDATE ON `postCode` FOR EACH ROW BEGIN - DECLARE vParentFk INT; - + IF !(OLD.townFk <=> NEW.townFk) THEN + CALL zoneGeo_setParent(NEW.geoFk, + (SELECT geoFk FROM town WHERE id = NEW.townFk)); + END IF; + 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 */ ; @@ -24959,6 +26569,22 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `postCodeBack__` +-- + +DROP TABLE IF EXISTS `postCodeBack__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `postCodeBack__` ( + `code` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `townFk` int(11) NOT NULL, + `geoFk` int(11) DEFAULT NULL, + PRIMARY KEY (`code`,`townFk`), + KEY `postCodeTownFk_idx2` (`townFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `preparationException` -- @@ -24974,13 +26600,52 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `priceBuilderKk` +-- Table structure for table `priceBuilderTag__` -- -DROP TABLE IF EXISTS `priceBuilderKk`; +DROP TABLE IF EXISTS `priceBuilderTag__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilderKk` ( +CREATE TABLE `priceBuilderTag__` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `priceBuilderFk` int(11) NOT NULL, + `tagFk` int(11) NOT NULL, + `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `priceBuilderTag_fk1_idx` (`priceBuilderFk`), + KEY `priceBuilderTag_fk2_idx` (`tagFk`), + CONSTRAINT `priceBuilderTag_fk1` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `priceBuilderTag_fk2` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `priceBuilderWarehouse__` +-- + +DROP TABLE IF EXISTS `priceBuilderWarehouse__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `priceBuilderWarehouse__` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `warehouseFk` smallint(6) unsigned NOT NULL, + `priceBuilderFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `priceBuilderWarehouse_fk1_idx` (`warehouseFk`), + KEY `priceBuilderWarehouse_fk2_idx` (`priceBuilderFk`), + CONSTRAINT `priceBuilderWarehouse_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `priceBuilderWarehouse_fk2` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `priceBuilder__` +-- + +DROP TABLE IF EXISTS `priceBuilder__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `priceBuilder__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `itemTypeFk` smallint(5) unsigned NOT NULL COMMENT 'Sirve para definir precios en tarifa2 para grupos de items', @@ -24996,45 +26661,6 @@ CREATE TABLE `priceBuilderKk` ( ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `priceBuilderTagKk` --- - -DROP TABLE IF EXISTS `priceBuilderTagKk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilderTagKk` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `priceBuilderFk` int(11) NOT NULL, - `tagFk` int(11) NOT NULL, - `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `priceBuilderTag_fk1_idx` (`priceBuilderFk`), - KEY `priceBuilderTag_fk2_idx` (`tagFk`), - CONSTRAINT `priceBuilderTag_fk1` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilderKk` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `priceBuilderTag_fk2` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `priceBuilderWarehouseKk` --- - -DROP TABLE IF EXISTS `priceBuilderWarehouseKk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `priceBuilderWarehouseKk` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `warehouseFk` smallint(6) unsigned NOT NULL, - `priceBuilderFk` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `priceBuilderWarehouse_fk1_idx` (`warehouseFk`), - KEY `priceBuilderWarehouse_fk2_idx` (`priceBuilderFk`), - CONSTRAINT `priceBuilderWarehouse_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `priceBuilderWarehouse_fk2` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilderKk` (`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 */; - -- -- Temporary table structure for view `priceFixed` -- @@ -25138,14 +26764,30 @@ CREATE TABLE `printingQueueCheck` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `producer` +-- Table structure for table `producer` -- DROP TABLE IF EXISTS `producer`; -/*!50001 DROP VIEW IF EXISTS `producer`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `producer` ( + `id` mediumint(3) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `isVisible` tinyint(1) NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=13508 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `producer__` +-- + +DROP TABLE IF EXISTS `producer__`; +/*!50001 DROP VIEW IF EXISTS `producer__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `producer` AS SELECT +/*!50001 CREATE VIEW `producer__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `isVisible`*/; @@ -25215,14 +26857,145 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `province` +-- Table structure for table `province` -- DROP TABLE IF EXISTS `province`; -/*!50001 DROP VIEW IF EXISTS `province`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `province` ( + `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `countryFk` mediumint(8) unsigned NOT NULL, + `warehouseFk` smallint(6) unsigned DEFAULT NULL COMMENT 'warehouse responsable de las rutas', + `zoneFk` tinyint(4) DEFAULT NULL, + `nstGeoFk` int(11) DEFAULT NULL, + `nstName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `geoFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `Paises_Id` (`countryFk`), + KEY `warehouse_Id` (`warehouseFk`), + KEY `provicne_zone_fk_idx` (`zoneFk`), + CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=208 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`.`province_beforeInsert` + BEFORE INSERT ON `province` FOR EACH ROW +BEGIN + 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 country WHERE id = NEW.countryFk; + + SET NEW.geoFk = 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_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`.`province_beforeUpdate` + BEFORE UPDATE ON `province` 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`.`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 zoneGeo SET `name` = NEW.`name` + WHERE id = NEW.geoFk; + END IF; + + IF !(OLD.countryFk <=> NEW.countryFk) THEN + SELECT geoFk INTO vParentFk + FROM country WHERE id = NEW.countryFk; + + 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`.`province_afterDelete` + AFTER DELETE ON `province` 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 `province__` +-- + +DROP TABLE IF EXISTS `province__`; +/*!50001 DROP VIEW IF EXISTS `province__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `province` AS SELECT +/*!50001 CREATE VIEW `province__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `countryFk`, @@ -25232,14 +27005,42 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `queuePriority` +-- Table structure for table `punchState` +-- + +DROP TABLE IF EXISTS `punchState`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `punchState` ( + `workerFk` int(11) NOT NULL, + `state` tinyint(4) DEFAULT '0', + PRIMARY KEY (`workerFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Table for storing punches that have cars with errors'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `queuePriority` -- DROP TABLE IF EXISTS `queuePriority`; -/*!50001 DROP VIEW IF EXISTS `queuePriority`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `queuePriority` ( + `id` tinyint(3) unsigned NOT NULL DEFAULT '0', + `priority` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `queuePriority__` +-- + +DROP TABLE IF EXISTS `queuePriority__`; +/*!50001 DROP VIEW IF EXISTS `queuePriority__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `queuePriority` AS SELECT +/*!50001 CREATE VIEW `queuePriority__` AS SELECT 1 AS `id`, 1 AS `priority`*/; SET character_set_client = @saved_cs_client; @@ -25302,14 +27103,35 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `recovery` +-- Table structure for table `recovery` -- DROP TABLE IF EXISTS `recovery`; -/*!50001 DROP VIEW IF EXISTS `recovery`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `recovery` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL DEFAULT '0', + `started` date NOT NULL COMMENT 'Fecha a partir de la que comienza el recobro', + `finished` date DEFAULT NULL COMMENT 'Fecha en la que acaba', + `amount` double NOT NULL, + `period` tinyint(3) unsigned NOT NULL DEFAULT '7' COMMENT 'numero de dias que indica cada cuanto hare el recobro', + PRIMARY KEY (`id`), + KEY `cliente_idx` (`clientFk`), + CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=311 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 */; + +-- +-- Temporary table structure for view `recovery__` +-- + +DROP TABLE IF EXISTS `recovery__`; +/*!50001 DROP VIEW IF EXISTS `recovery__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `recovery` AS SELECT +/*!50001 CREATE VIEW `recovery__` AS SELECT 1 AS `id`, 1 AS `clientFk`, 1 AS `started`, @@ -25361,30 +27183,90 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `route` +-- Table structure for table `route` -- DROP TABLE IF EXISTS `route`; -/*!50001 DROP VIEW IF EXISTS `route`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `route` AS SELECT - 1 AS `id`, - 1 AS `workerFk`, - 1 AS `created`, - 1 AS `vehicleFk`, - 1 AS `agencyModeFk`, - 1 AS `time`, - 1 AS `isOk`, - 1 AS `kmStart`, - 1 AS `kmEnd`, - 1 AS `started`, - 1 AS `finished`, - 1 AS `gestdocFk`, - 1 AS `cost`, - 1 AS `m3`, - 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 `route` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `workerFk` int(10) unsigned DEFAULT NULL, + `created` date NOT NULL, + `vehicleFk` int(10) unsigned DEFAULT NULL, + `agencyModeFk` int(11) DEFAULT NULL, + `time` datetime DEFAULT NULL, + `isOk` tinyint(1) unsigned NOT NULL DEFAULT '0', + `kmStart` mediumint(9) NOT NULL, + `kmEnd` mediumint(9) NOT NULL, + `started` datetime NOT NULL, + `finished` datetime NOT NULL, + `gestdocFk` int(11) DEFAULT NULL, + `cost` double unsigned DEFAULT NULL, + `m3` decimal(10,1) unsigned DEFAULT NULL, + `description` text COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`), + KEY `Id_Agencia` (`agencyModeFk`), + KEY `Fecha` (`created`), + KEY `gestdoc_id` (`gestdocFk`), + CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=58055 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`.`route_beforeUpdate` + BEFORE UPDATE ON `route` FOR EACH ROW +BEGIN + IF NEW.isOk <> FALSE AND OLD.isOk = FALSE THEN + 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); + 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`.`route_afterUpdate` + AFTER UPDATE ON `route` FOR EACH ROW +BEGIN + IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN + -- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets + + -- Inserta el gestdoc en todos los tickets de la ruta + INSERT INTO ticketDms(ticketFk,dmsFk) + SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id + ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk; + + -- Update del firmado + UPDATE ticket t + JOIN ticketDms tg ON t.id = tg.ticketFk + SET isSigned = 1 WHERE t.routeFk = NEW.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 */ ; -- -- Table structure for table `routeAction` @@ -25419,7 +27301,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=782 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=901 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25493,7 +27375,7 @@ CREATE TABLE `routeLoadWorker` ( `workerFk` int(11) NOT NULL, PRIMARY KEY (`routeFk`,`workerFk`), KEY `frmWorker_idx` (`workerFk`), - CONSTRAINT `frmRutas` FOREIGN KEY (`routeFk`) REFERENCES `vn2008`.`Rutas` (`Id_Ruta`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `frmRutas` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frmWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25520,9 +27402,9 @@ CREATE TABLE `routeLog` ( PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), - CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Rutas` (`Id_Ruta`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=99936 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=137343 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25562,9 +27444,35 @@ CREATE TABLE `routeUserPercentage` ( PRIMARY KEY (`id`), KEY `routeUserPercentageFk_idx` (`workerFk`), CONSTRAINT `routeUserPercentageFk` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `route__` +-- + +DROP TABLE IF EXISTS `route__`; +/*!50001 DROP VIEW IF EXISTS `route__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `route__` AS SELECT + 1 AS `id`, + 1 AS `workerFk`, + 1 AS `created`, + 1 AS `vehicleFk`, + 1 AS `agencyModeFk`, + 1 AS `time`, + 1 AS `isOk`, + 1 AS `kmStart`, + 1 AS `kmEnd`, + 1 AS `started`, + 1 AS `finished`, + 1 AS `gestdocFk`, + 1 AS `cost`, + 1 AS `m3`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `routesControl` -- @@ -25582,50 +27490,185 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `sale` +-- Table structure for table `sale` -- DROP TABLE IF EXISTS `sale`; -/*!50001 DROP VIEW IF EXISTS `sale`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `sale` AS SELECT - 1 AS `id`, - 1 AS `itemFk`, - 1 AS `ticketFk`, - 1 AS `concept`, - 1 AS `quantity`, - 1 AS `price`, - 1 AS `discount`, - 1 AS `reserved`, - 1 AS `isPicked`, - 1 AS `created`, - 1 AS `priceFixed`, - 1 AS `isPriceFixed`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sale` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `ticketFk` int(11) NOT NULL, + `concept` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `quantity` decimal(10,2) NOT NULL DEFAULT '0.00', + `originalQuantity` double(9,1) DEFAULT NULL, + `price` decimal(10,2) DEFAULT '0.00', + `discount` tinyint(2) unsigned NOT NULL DEFAULT '0', + `priceFixed` decimal(10,2) NOT NULL DEFAULT '0.00', + `reserved` tinyint(1) NOT NULL DEFAULT '0', + `isPicked` tinyint(1) NOT NULL DEFAULT '0', + `isPriceFixed` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `Id_Ticket` (`ticketFk`), + KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), + CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=26058259 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 `sale_afterInsert` + AFTER INSERT ON `sale` + FOR EACH ROW +BEGIN + CALL stock.log_add('sale', NEW.id, 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 `sale_beforeUpdate` + BEFORE UPDATE ON `sale` + FOR EACH ROW +BEGIN + IF NEW.discount > 100 THEN + SET NEW.discount = 0; + 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 `sale_afterUpdate` + AFTER UPDATE ON `sale` + FOR EACH ROW +BEGIN + IF !(NEW.id <=> OLD.id) + OR !(NEW.ticketFk <=> OLD.ticketFk) + OR !(NEW.itemFk <=> OLD.itemFk) + OR !(NEW.quantity <=> OLD.quantity) + OR !(NEW.created <=> OLD.created) + OR !(NEW.isPicked <=> OLD.isPicked) THEN + CALL stock.log_add('sale', NEW.id, OLD.id); + END IF; + + IF !(OLD.ticketFk <=> NEW.ticketFk) THEN + UPDATE ticketRequest SET ticketFk = NEW.ticketFk + WHERE saleFk = NEW.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 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 `sale_afterDelete` + AFTER DELETE ON `sale` + FOR EACH ROW +BEGIN + CALL stock.log_add('sale', NULL, OLD.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 */ ; -- --- Temporary table structure for view `saleChecked` +-- Table structure for table `saleChecked` -- DROP TABLE IF EXISTS `saleChecked`; -/*!50001 DROP VIEW IF EXISTS `saleChecked`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `saleChecked` ( + `saleFk` int(11) NOT NULL, + `isChecked` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`saleFk`), + CONSTRAINT `fk_Movimientos_checked_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `saleChecked__` +-- + +DROP TABLE IF EXISTS `saleChecked__`; +/*!50001 DROP VIEW IF EXISTS `saleChecked__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleChecked` AS SELECT +/*!50001 CREATE VIEW `saleChecked__` AS SELECT 1 AS `saleFk`, 1 AS `isChecked`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `saleComponent` +-- Table structure for table `saleComponent` -- DROP TABLE IF EXISTS `saleComponent`; -/*!50001 DROP VIEW IF EXISTS `saleComponent`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `saleComponent` ( + `saleFk` int(11) NOT NULL, + `componentFk` int(11) NOT NULL, + `value` double NOT NULL, + `isGreuge` tinyint(4) NOT NULL DEFAULT '0', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`saleFk`,`componentFk`), + KEY `fk_mov_comp_idx` (`componentFk`), + CONSTRAINT `mc_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `mc_fk2` FOREIGN KEY (`componentFk`) REFERENCES `bi`.`tarifa_componentes` (`Id_Componente`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `saleComponent__` +-- + +DROP TABLE IF EXISTS `saleComponent__`; +/*!50001 DROP VIEW IF EXISTS `saleComponent__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleComponent` AS SELECT +/*!50001 CREATE VIEW `saleComponent__` AS SELECT 1 AS `saleFk`, 1 AS `componentFk`, 1 AS `value`, @@ -25684,20 +27727,68 @@ CREATE TABLE `saleState` ( `stateFk` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`saleFk`), KEY `saleState_fk2_idx` (`stateFk`), - CONSTRAINT `saleState_fk1` FOREIGN KEY (`saleFk`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `saleState_fk2` FOREIGN KEY (`stateFk`) REFERENCES `vn2008`.`state` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `saleState_fk1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `saleState_fk2` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='cahce para el estado de la linea'; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `saleTracking` +-- Table structure for table `saleTracking` -- DROP TABLE IF EXISTS `saleTracking`; -/*!50001 DROP VIEW IF EXISTS `saleTracking`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `saleTracking` ( + `saleFk` int(11) NOT NULL, + `isChecked` tinyint(3) unsigned NOT NULL DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `originalQuantity` double DEFAULT NULL, + `workerFk` int(11) NOT NULL, + `actionFk` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `stateFk` tinyint(3) unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `stateFk_UNIQUE` (`stateFk`,`saleFk`), + KEY `Id_Movimiento` (`saleFk`), + KEY `fgnStateFk_idx` (`stateFk`), + CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=20057318 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`.`saleTracking_beforeInsert` BEFORE INSERT ON `saleTracking` FOR EACH ROW +BEGIN + IF(NEW.stateFk = 14) THEN + SET NEW.actionFk = 3; + END IF; + + IF(NEW.stateFk = 8) THEN + SET NEW.actionFk = 4; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Temporary table structure for view `saleTracking__` +-- + +DROP TABLE IF EXISTS `saleTracking__`; +/*!50001 DROP VIEW IF EXISTS `saleTracking__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleTracking` AS SELECT +/*!50001 CREATE VIEW `saleTracking__` AS SELECT 1 AS `saleFk`, 1 AS `isChecked`, 1 AS `created`, @@ -25722,21 +27813,61 @@ SET character_set_client = utf8; 1 AS `litros`, 1 AS `routeFk`, 1 AS `shipped`, - 1 AS `volume`*/; + 1 AS `volume`, + 1 AS `physicalWeight`, + 1 AS `physicalVolume`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `saleVolume__` +-- Temporary table structure for view `sale__` -- -DROP TABLE IF EXISTS `saleVolume__`; -/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +DROP TABLE IF EXISTS `sale__`; +/*!50001 DROP VIEW IF EXISTS `sale__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleVolume__` AS SELECT +/*!50001 CREATE VIEW `sale__` AS SELECT + 1 AS `id`, + 1 AS `itemFk`, 1 AS `ticketFk`, - 1 AS `saleFk`, - 1 AS `litros`*/; + 1 AS `concept`, + 1 AS `quantity`, + 1 AS `price`, + 1 AS `discount`, + 1 AS `reserved`, + 1 AS `isPicked`, + 1 AS `created`, + 1 AS `priceFixed`, + 1 AS `isPriceFixed`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `salesToPrePrepare` +-- + +DROP TABLE IF EXISTS `salesToPrePrepare`; +/*!50001 DROP VIEW IF EXISTS `salesToPrePrepare`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `salesToPrePrepare` AS SELECT + 1 AS `Id_Ticket`, + 1 AS `Id_Movimiento`, + 1 AS `Id_Movimiento_mark`, + 1 AS `Id_Trabjador`, + 1 AS `Id_Article`, + 1 AS `Concepte`, + 1 AS `subName`, + 1 AS `Cantidad`, + 1 AS `original_quantity`, + 1 AS `Hora`, + 1 AS `Departure`, + 1 AS `Minuto`, + 1 AS `agency_id`, + 1 AS `warehouse_id`, + 1 AS `province_id`, + 1 AS `picked`, + 1 AS `trabajador`, + 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; -- @@ -25766,21 +27897,96 @@ CREATE TABLE `sector` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `isPreviousPreparedByPacking` tinyint(4) NOT NULL DEFAULT '1', + `code` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `pickingPlacement` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `path` int(11) DEFAULT NULL, PRIMARY KEY (`id`,`warehouseFk`), + UNIQUE KEY `code_UNIQUE` (`code`), 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=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `sharingCart` +-- Table structure for table `sharingCart` -- DROP TABLE IF EXISTS `sharingCart`; -/*!50001 DROP VIEW IF EXISTS `sharingCart`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sharingCart` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `workerFk` int(11) NOT NULL, + `started` date NOT NULL, + `ended` date NOT NULL, + `workerSubstitute` int(11) NOT NULL, + `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `Worker` (`workerFk`), + KEY `Suplent` (`workerSubstitute`), + CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2179 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`.`sharingCart_beforeInsert` BEFORE INSERT ON `sharingCart` FOR EACH ROW + +BEGIN + SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(CURDATE(),NEW.ended); + + IF NEW.workerFk = NEW.workerSubstitute THEN + SET NEW.workerFk = NULL; +END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!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`.`sharingCart_beforeUpdate` BEFORE UPDATE ON `sharingCart` FOR EACH ROW + +BEGIN + SET NEW.started = GREATEST(CURDATE(),NEW.started); + SET NEW.ended = GREATEST(CURDATE(),NEW.ended); + + IF NEW.workerFk = NEW.workerSubstitute THEN + SET NEW.workerFk = NULL; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Temporary table structure for view `sharingCart__` +-- + +DROP TABLE IF EXISTS `sharingCart__`; +/*!50001 DROP VIEW IF EXISTS `sharingCart__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `sharingCart` AS SELECT +/*!50001 CREATE VIEW `sharingCart__` AS SELECT 1 AS `id`, 1 AS `workerFk`, 1 AS `started`, @@ -25790,14 +27996,73 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `sharingClient` +-- Table structure for table `sharingClient` -- DROP TABLE IF EXISTS `sharingClient`; -/*!50001 DROP VIEW IF EXISTS `sharingClient`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sharingClient` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `workerFk` int(11) NOT NULL, + `started` date NOT NULL, + `ended` date NOT NULL, + `clientFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `Worker` (`workerFk`), + KEY `Client` (`clientFk`), + CONSTRAINT `Clients_key` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `Trabajadores_key` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=47 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`.`sharingClient_beforeInsert` BEFORE INSERT ON `sharingClient` FOR EACH ROW +BEGIN + SET NEW.ended = GREATEST(CURDATE(),NEW.ended); + SET NEW.started = GREATEST(CURDATE(),NEW.started); +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`.`sharingClient_beforeUpdate` BEFORE UPDATE ON `sharingClient` FOR EACH ROW +BEGIN + SET NEW.ended = GREATEST(CURDATE(),NEW.ended); + SET NEW.started = GREATEST(CURDATE(),NEW.started); +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 `sharingClient__` +-- + +DROP TABLE IF EXISTS `sharingClient__`; +/*!50001 DROP VIEW IF EXISTS `sharingClient__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `sharingClient` AS SELECT +/*!50001 CREATE VIEW `sharingClient__` AS SELECT 1 AS `id`, 1 AS `workerFk`, 1 AS `started`, @@ -25835,12 +28100,17 @@ 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(); + UPDATE item i + JOIN itemShelving ish ON ish.itemFk = i.id + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + SET i.sectorFk = p.sectorFk + WHERE sh.`code` = OLD.`code`; END IF; -*/ + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25866,7 +28136,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=144655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=148755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25996,21 +28266,44 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `state` +-- Table structure for table `state` -- DROP TABLE IF EXISTS `state`; -/*!50001 DROP VIEW IF EXISTS `state`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `state` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `order` tinyint(3) unsigned DEFAULT NULL, + `alertLevel` 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', + `isPicked` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `code_UNIQUE` (`code`) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `state__` +-- + +DROP TABLE IF EXISTS `state__`; +/*!50001 DROP VIEW IF EXISTS `state__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `state` AS SELECT +/*!50001 CREATE VIEW `state__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `order`, 1 AS `alertLevel`, 1 AS `code`, 1 AS `sectorProdPriority`, - 1 AS `isPreviousPreparable`*/; + 1 AS `isPreviousPreparable`, + 1 AS `isPicked`*/; SET character_set_client = @saved_cs_client; -- @@ -26032,7 +28325,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=779069 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=814563 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26051,48 +28344,97 @@ CREATE TABLE `stowaway` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `supplier` +-- Table structure for table `supplier` -- DROP TABLE IF EXISTS `supplier`; -/*!50001 DROP VIEW IF EXISTS `supplier`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `supplier` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `account`, - 1 AS `countryFk`, - 1 AS `nif`, - 1 AS `isFarmer`, - 1 AS `phone`, - 1 AS `retAccount`, - 1 AS `commission`, - 1 AS `created`, - 1 AS `postcodeFk`, - 1 AS `isActive`, - 1 AS `street`, - 1 AS `city`, - 1 AS `provinceFk`, - 1 AS `postCode`, - 1 AS `payMethodFk`, - 1 AS `payDemFk`, - 1 AS `nickname`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `supplier` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `account` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `street` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `postCode__` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'deprecada', + `city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `provinceFk` smallint(5) unsigned DEFAULT NULL, + `countryFk` mediumint(8) unsigned DEFAULT NULL, + `nif` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `isOfficial` tinyint(1) NOT NULL DEFAULT '1', + `isFarmer` tinyint(1) NOT NULL DEFAULT '0', + `retAccount` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `phone` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, + `Fax` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, + `commission` float NOT NULL DEFAULT '0', + `nickname` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `payMethodFk` tinyint(3) unsigned NOT NULL, + `payDay` tinyint(4) unsigned DEFAULT NULL, + `payDemFk` tinyint(3) unsigned NOT NULL DEFAULT '7', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `isSerious` tinyint(1) unsigned zerofill DEFAULT '1', + `note` text COLLATE utf8_unicode_ci, + `postcodeFk` int(11) unsigned DEFAULT NULL, + `postCode` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `isActive` tinyint(4) DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `cuenta` (`account`), + UNIQUE KEY `NIF` (`nif`), + KEY `pais_id` (`countryFk`), + KEY `pay_met_id` (`payMethodFk`), + KEY `province_id` (`provinceFk`), + KEY `pay_dem_id` (`payDemFk`), + KEY `codpos` (`postCode`,`postCode__`), + CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, + CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE, + CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2908 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `supplierAccount` +-- Table structure for table `supplierAccount` -- DROP TABLE IF EXISTS `supplierAccount`; -/*!50001 DROP VIEW IF EXISTS `supplierAccount`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `supplierAccount` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `supplierFk` int(11) NOT NULL, + `iban` varchar(30) CHARACTER SET utf8 DEFAULT NULL, + `office` varchar(4) CHARACTER SET utf8 DEFAULT NULL, + `DC` varchar(2) CHARACTER SET utf8 DEFAULT NULL, + `number` varchar(10) CHARACTER SET utf8 DEFAULT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'obsoleta(comprobar)', + `bicSufix` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', + `bankEntityFk` int(10) DEFAULT NULL, + `bankFk` int(11) DEFAULT NULL COMMENT 'obsoleta(comprobar)', + PRIMARY KEY (`id`), + KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), + KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), + KEY `fk_banco_prov_account_idx` (`bankFk`) +) ENGINE=InnoDB AUTO_INCREMENT=860 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `supplierAccount__` +-- + +DROP TABLE IF EXISTS `supplierAccount__`; +/*!50001 DROP VIEW IF EXISTS `supplierAccount__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `supplierAccount` AS SELECT +/*!50001 CREATE VIEW `supplierAccount__` AS SELECT 1 AS `id`, 1 AS `supplierFk`, 1 AS `iban`, - 1 AS `bankEntityFk`*/; + 1 AS `bankEntityFk`, + 1 AS `office`, + 1 AS `DC`, + 1 AS `number`, + 1 AS `description`, + 1 AS `bankFk`, + 1 AS `bicSufix`*/; SET character_set_client = @saved_cs_client; -- @@ -26115,6 +28457,67 @@ SET character_set_client = utf8; 1 AS `almacen`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `supplier__` +-- + +DROP TABLE IF EXISTS `supplier__`; +/*!50001 DROP VIEW IF EXISTS `supplier__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `supplier__` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `account`, + 1 AS `countryFk`, + 1 AS `nif`, + 1 AS `isFarmer`, + 1 AS `phone`, + 1 AS `retAccount`, + 1 AS `commission`, + 1 AS `created`, + 1 AS `postcodeFk`, + 1 AS `isActive`, + 1 AS `street`, + 1 AS `city`, + 1 AS `provinceFk`, + 1 AS `postCode`, + 1 AS `payMethodFk`, + 1 AS `payDemFk`, + 1 AS `nickname`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `tablet` +-- + +DROP TABLE IF EXISTS `tablet`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tablet` ( + `uuid` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `place` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `tabletDepartment` +-- + +DROP TABLE IF EXISTS `tabletDepartment`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tabletDepartment` ( + `tabletFk` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `departmentFk` int(11) NOT NULL, + PRIMARY KEY (`tabletFk`,`departmentFk`), + KEY `departmentFk_idx` (`departmentFk`), + CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `vn2008`.`department` (`department_id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `tag` -- @@ -26133,7 +28536,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=109 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; +) ENGINE=InnoDB AUTO_INCREMENT=110 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26194,64 +28597,110 @@ CREATE TABLE `taxArea` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `taxClass` +-- Table structure for table `taxClass` -- DROP TABLE IF EXISTS `taxClass`; -/*!50001 DROP VIEW IF EXISTS `taxClass`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `taxClass` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'R', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `taxClassCode` +-- + +DROP TABLE IF EXISTS `taxClassCode`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `taxClassCode` ( + `taxClassFk` tinyint(3) unsigned NOT NULL, + `effectived` date NOT NULL, + `taxCodeFk` tinyint(3) unsigned NOT NULL, + PRIMARY KEY (`taxClassFk`,`effectived`,`taxCodeFk`), + KEY `iva_codigo_id` (`taxCodeFk`), + CONSTRAINT `taxClassCode_ibfk_1` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, + CONSTRAINT `taxClassCode_ibfk_2` FOREIGN KEY (`taxCodeFk`) REFERENCES `taxCode` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `taxClass__` +-- + +DROP TABLE IF EXISTS `taxClass__`; +/*!50001 DROP VIEW IF EXISTS `taxClass__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `taxClass` AS SELECT +/*!50001 CREATE VIEW `taxClass__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `code`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `taxClassCode` --- - -DROP TABLE IF EXISTS `taxClassCode`; -/*!50001 DROP VIEW IF EXISTS `taxClassCode`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `taxClassCode` AS SELECT - 1 AS `taxClassFk`, - 1 AS `effectived`, - 1 AS `taxCodeFk`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `taxCode` +-- Table structure for table `taxCode` -- DROP TABLE IF EXISTS `taxCode`; -/*!50001 DROP VIEW IF EXISTS `taxCode`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `taxCode` AS SELECT - 1 AS `id`, - 1 AS `dated`, - 1 AS `code`, - 1 AS `taxTypeFk`, - 1 AS `rate`, - 1 AS `equalizationTax`, - 1 AS `type`, - 1 AS `link`, - 1 AS `isActive`, - 1 AS `updated`, - 1 AS `transactionCode`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `taxCode` ( + `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, + `dated` date NOT NULL, + `code` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `taxTypeFk` tinyint(2) NOT NULL, + `rate` decimal(4,1) NOT NULL DEFAULT '0.0', + `equalizationTax` decimal(4,1) NOT NULL DEFAULT '0.0', + `type` char(1) COLLATE utf8_unicode_ci NOT NULL, + `link` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', + `isActive` tinyint(2) NOT NULL DEFAULT '1', + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `transactionCode` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `iva_tipo_id` (`taxTypeFk`), + KEY `codigo` (`code`), + KEY `tipo_index` (`type`), + CONSTRAINT `taxCode_ibfk_1` FOREIGN KEY (`taxTypeFk`) REFERENCES `taxType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `taxType` +-- Table structure for table `taxType` -- DROP TABLE IF EXISTS `taxType`; -/*!50001 DROP VIEW IF EXISTS `taxType`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `taxType` ( + `id` tinyint(2) NOT NULL AUTO_INCREMENT, + `nickname` varchar(6) COLLATE utf8_unicode_ci NOT NULL, + `isAccrued` tinyint(4) NOT NULL DEFAULT '0', + `serial` char(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ' COMMENT 'respetar el nombre de la columna, se utiliza en contaplus', + `description` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `countryFk` mediumint(8) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `serie_id` (`serial`), + KEY `Id_Pais` (`countryFk`), + CONSTRAINT `taxType_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `taxType__` +-- + +DROP TABLE IF EXISTS `taxType__`; +/*!50001 DROP VIEW IF EXISTS `taxType__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `taxType` AS SELECT +/*!50001 CREATE VIEW `taxType__` AS SELECT 1 AS `id`, 1 AS `nickname`, 1 AS `isAccrued`, @@ -26262,33 +28711,184 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `ticket` +-- Table structure for table `ticket` -- DROP TABLE IF EXISTS `ticket`; -/*!50001 DROP VIEW IF EXISTS `ticket`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticket` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `warehouseFk`, - 1 AS `shipped`, - 1 AS `landed`, - 1 AS `nickname`, - 1 AS `refFk`, - 1 AS `addressFk`, - 1 AS `location`, - 1 AS `solution`, - 1 AS `routeFk`, - 1 AS `companyFk`, - 1 AS `agencyModeFk`, - 1 AS `priority`, - 1 AS `packages`, - 1 AS `isDeleted`, - 1 AS `created`, - 1 AS `zoneFk`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticket` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL DEFAULT '0', + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + `shipped` datetime NOT NULL, + `nickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `notes` longtext COLLATE utf8_unicode_ci, + `refFk` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `invoiceOutFk` int(10) unsigned DEFAULT NULL COMMENT 'eliminar', + `isBooked` tinyint(1) NOT NULL DEFAULT '0', + `addressFk` int(11) NOT NULL DEFAULT '0', + `workerFk` int(11) DEFAULT NULL, + `observations` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'eliminar', + `isSigned` tinyint(1) NOT NULL DEFAULT '0', + `isLabeled` tinyint(1) NOT NULL DEFAULT '0', + `isPrinted` tinyint(1) NOT NULL DEFAULT '0', + `packages` smallint(10) unsigned DEFAULT '0', + `location` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, + `hour` int(11) DEFAULT '0', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `isBlocked` tinyint(1) NOT NULL DEFAULT '1', + `solution` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `routeFk` int(10) unsigned DEFAULT NULL, + `priority` tinyint(3) unsigned DEFAULT NULL, + `hasPriority` tinyint(1) unsigned NOT NULL DEFAULT '1', + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `agencyModeFk` int(11) DEFAULT NULL, + `landed` date DEFAULT NULL, + `isBoxed` tinyint(2) NOT NULL DEFAULT '0', + `isDeleted` tinyint(2) NOT NULL DEFAULT '0', + `zoneFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `Id_Cliente` (`clientFk`), + KEY `Id_Consigna` (`addressFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `warehouse_id` (`warehouseFk`), + KEY `empresa_id` (`companyFk`), + KEY `Id_Agencia` (`agencyModeFk`), + KEY `Factura` (`refFk`), + KEY `Id_Ruta` (`routeFk`), + KEY `warehouse_date` (`warehouseFk`,`shipped`), + KEY `Fecha` (`shipped`,`clientFk`), + KEY `tickets_zone_fk_idx` (`zoneFk`), + CONSTRAINT `ticket_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticket_ibfk_5` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticket_ibfk_6` FOREIGN KEY (`addressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, + CONSTRAINT `ticket_ibfk_8` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`), + CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, + CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, + CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2431569 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 `ticket_afterInsert` + AFTER INSERT ON `ticket` + FOR EACH ROW +BEGIN + DECLARE vClientType VARCHAR(255); + DECLARE vStateCode VARCHAR(255); + + -- Borrar cuando se cambie el insert ticket en la APP móvil + + SELECT typeFk INTO vClientType + FROM vn.`client` WHERE id = NEW.clientFk; + + IF vClientType = 'loses' THEN + SET vStateCode = 'DELIVERED'; + ELSE + SET vStateCode = 'FREE'; + END IF; + + INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador) + SELECT NEW.id, id, vn.myWorker_getId() + FROM state + WHERE `code` = vStateCode 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 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 `ticket_beforeUpdate` + BEFORE UPDATE ON `ticket` + FOR EACH ROW +BEGIN + IF !(NEW.shipped <=> OLD.shipped) THEN + IF YEAR(NEW.shipped) < 2000 THEN + SIGNAL SQLSTATE '46000' + SET MESSAGE_TEXT = 'Year cannot be lesser than 2000'; + END IF; + + IF YEAR(NEW.shipped) = 2000 THEN + SET NEW.isDeleted = TRUE; + END IF; + END IF; + + IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN + SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); + SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); + SET NEW.routeFk = NULL; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!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 `ticket_afterUpdate` + AFTER UPDATE ON `ticket` + FOR EACH ROW +BEGIN + IF !(NEW.id <=> OLD.id) + OR !(NEW.warehouseFk <=> OLD.warehouseFk) + OR !(NEW.shipped <=> OLD.shipped) THEN + CALL stock.log_add('ticket', NEW.id, OLD.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 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 `ticket_beforeDelete` + BEFORE DELETE ON `ticket` + FOR EACH ROW +BEGIN + DELETE FROM sale WHERE ticketFk = OLD.id; + + DELETE FROM ticketDms WHERE ticketFk = OLD.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 */ ; -- -- Table structure for table `ticketConfig` @@ -26330,7 +28930,8 @@ CREATE TABLE `ticketDown` ( `selected` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ticketFk`), KEY `created_idx` (`created`), - KEY `selected_idx` (`selected`) + KEY `selected_idx` (`selected`), + CONSTRAINT `ticketDown_fk1` FOREIGN KEY (`selected`) REFERENCES `ticketDown_SelectionType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola de impresion para los tickets que se van a solicitar al altillo'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26351,14 +28952,29 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `ticketGetVolume` +-- Table structure for table `ticketDown_SelectionType` -- -DROP TABLE IF EXISTS `ticketGetVolume`; -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume`*/; +DROP TABLE IF EXISTS `ticketDown_SelectionType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketDown_SelectionType` ( + `id` int(11) NOT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `description_UNIQUE` (`description`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ticketGetVolume__` +-- + +DROP TABLE IF EXISTS `ticketGetVolume__`; +/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketGetVolume` AS SELECT +/*!50001 CREATE VIEW `ticketGetVolume__` AS SELECT 1 AS `ticketFk`, 1 AS `routeFk`, 1 AS `saleFk`, @@ -26388,9 +29004,9 @@ CREATE TABLE `ticketLog` ( PRIMARY KEY (`id`), KEY `logTicketoriginFk` (`originFk`), KEY `logTicketuserFk` (`userFk`), - CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7020289 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7462981 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26411,14 +29027,34 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `ticketObservation` +-- Table structure for table `ticketObservation` -- DROP TABLE IF EXISTS `ticketObservation`; -/*!50001 DROP VIEW IF EXISTS `ticketObservation`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketObservation` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `ticketFk` int(11) NOT NULL, + `observationTypeFk` tinyint(3) unsigned NOT NULL, + `description` text COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `Id_Ticket` (`ticketFk`,`observationTypeFk`), + KEY `observation_type_id` (`observationTypeFk`), + CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=1473664 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ticketObservation__` +-- + +DROP TABLE IF EXISTS `ticketObservation__`; +/*!50001 DROP VIEW IF EXISTS `ticketObservation__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketObservation` AS SELECT +/*!50001 CREATE VIEW `ticketObservation__` AS SELECT 1 AS `id`, 1 AS `ticketFk`, 1 AS `observationTypeFk`, @@ -26436,7 +29072,7 @@ CREATE TABLE `ticketPackage` ( `ticket` int(11) NOT NULL, `counter` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ticket`), - CONSTRAINT `ticketPackage_ticketFk` FOREIGN KEY (`ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `ticketPackage_ticketFk` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26459,10 +29095,10 @@ CREATE TABLE `ticketPackaging` ( KEY `ticketPackaging_fk1_idx` (`ticketFk`), KEY `ticketPackaging_fk2_idx` (`packagingFk`), KEY `ticketPackaging_fk3_idx` (`workerFk`), - 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_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=71087 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=73741 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 */ ; @@ -26502,21 +29138,163 @@ CREATE TABLE `ticketPackagingStartingStock` ( PRIMARY KEY (`clientFk`,`packagingFk`), KEY `ticketPackagingStartingStock_fk2_idx` (`packagingFk`), KEY `ticketPackagingStartingStock_fk3_idx` (`itemFk`), - CONSTRAINT `ticketPackagingStartingStock_fk1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketPackagingStartingStock_fk3` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `ticketPackagingStartingStock_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackagingStartingStock_fk3` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `ticketRequest` +-- Table structure for table `ticketParking` +-- + +DROP TABLE IF EXISTS `ticketParking`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketParking` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ticketFk` int(11) NOT NULL, + `parkingFk` int(11) NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `ticketParking_idx1` (`ticketFk`,`parkingFk`), + KEY `ticketParking_fk1_idx` (`parkingFk`), + CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3105 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ticketPreviousPreparingList` +-- + +DROP TABLE IF EXISTS `ticketPreviousPreparingList`; +/*!50001 DROP VIEW IF EXISTS `ticketPreviousPreparingList`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticketPreviousPreparingList` AS SELECT + 1 AS `ticketFk`, + 1 AS `code`, + 1 AS `saleLines`, + 1 AS `alreadyMadeSaleLines`, + 1 AS `madeRate`, + 1 AS `created`, + 1 AS `sectorFk`, + 1 AS `parking`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `ticketRequest` -- DROP TABLE IF EXISTS `ticketRequest`; -/*!50001 DROP VIEW IF EXISTS `ticketRequest`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketRequest` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `ordered` datetime DEFAULT NULL, + `shipped` datetime DEFAULT NULL, + `salesPersonCode` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `buyerCode` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'NOE', + `quantity` int(11) DEFAULT NULL, + `price` double DEFAULT NULL, + `price__` double DEFAULT NULL, + `itemFk` double DEFAULT NULL, + `clientFk` int(11) DEFAULT NULL, + `response` longtext COLLATE utf8_unicode_ci, + `ok__` tinyint(1) NOT NULL DEFAULT '0', + `total` int(11) DEFAULT NULL, + `buyed` datetime DEFAULT NULL, + `ko__` tinyint(1) NOT NULL DEFAULT '0', + `saleFk` int(11) DEFAULT NULL, + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `isOk` tinyint(1) DEFAULT NULL, + `requesterFk` int(11) DEFAULT NULL, + `atenderFk` int(11) DEFAULT NULL, + `ticketFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `Id_Movimiento_UNIQUE` (`saleFk`), + KEY `Id_ARTICLE` (`itemFk`), + KEY `Id_CLIENTE` (`clientFk`), + KEY `Id_Comprador` (`buyerCode`), + KEY `Id_Movimiento` (`saleFk`), + KEY `Id_Vendedor` (`salesPersonCode`), + KEY `fgnRequester_idx` (`requesterFk`), + KEY `fgnAtender_idx` (`atenderFk`), + KEY `fgnTicket_idx` (`ticketFk`), + CONSTRAINT `fgbMovimiento` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=50635 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`.`ticketRequest_beforeInsert` BEFORE INSERT ON `ticketRequest` FOR EACH ROW +BEGIN + IF NEW.ticketFk IS NULL THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; + + IF NEW.requesterFk IS NULL THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.atenderFk IS NULL THEN + SET NEW.atenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + 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`.`ticketRequest_beforeUpdate` BEFORE UPDATE ON `ticketRequest` FOR EACH ROW +BEGIN + IF NEW.saleFk <> OLD.saleFk THEN + SET NEW.ticketFk = (SELECT s.ticketFk FROM sale s WHERE s.id = NEW.saleFk); + END IF; + + IF NEW.salesPersonCode <> OLD.salesPersonCode THEN + SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); + END IF; + + IF NEW.buyerCode <> OLD.buyerCode THEN + SET NEW.atenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Temporary table structure for view `ticketRequest__` +-- + +DROP TABLE IF EXISTS `ticketRequest__`; +/*!50001 DROP VIEW IF EXISTS `ticketRequest__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketRequest` AS SELECT +/*!50001 CREATE VIEW `ticketRequest__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `requesterFk`, @@ -26548,8 +29326,8 @@ CREATE TABLE `ticketService` ( PRIMARY KEY (`id`), KEY `ticketServiceIvaGroup_idx` (`taxClassFk`), KEY `fgn_ticketFk_idx` (`ticketFk`), - CONSTRAINT `fgn_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketServiceIvaGroup` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE + CONSTRAINT `fgn_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketServiceIvaGroup` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servicios asociadas a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26586,7 +29364,8 @@ SET character_set_client = utf8; 1 AS `code`, 1 AS `ticket`, 1 AS `worker`, - 1 AS `isPreviousPreparable`*/; + 1 AS `isPreviousPreparable`, + 1 AS `isPicked`*/; SET character_set_client = @saved_cs_client; -- @@ -26604,7 +29383,8 @@ SET character_set_client = utf8; 1 AS `alertLevel`, 1 AS `worker`, 1 AS `code`, - 1 AS `updated`*/; + 1 AS `updated`, + 1 AS `isPicked`*/; SET character_set_client = @saved_cs_client; -- @@ -26632,7 +29412,8 @@ SET character_set_client = utf8; 1 AS `warehouse_id`, 1 AS `province_id`, 1 AS `picked`, - 1 AS `zoneFk`*/; + 1 AS `zoneFk`, + 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; -- @@ -26662,36 +29443,94 @@ CREATE TABLE `ticketTrolley` ( `ticket` int(11) NOT NULL, `labelCount` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ticket`), - CONSTRAINT `fk_ticketTrolley_vs_ticket` FOREIGN KEY (`ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `fk_ticketTrolley_vs_ticket` FOREIGN KEY (`ticket`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `ticketUpdateAction` +-- Table structure for table `ticketUpdateAction` -- DROP TABLE IF EXISTS `ticketUpdateAction`; -/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketUpdateAction` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ticketUpdateAction__` +-- + +DROP TABLE IF EXISTS `ticketUpdateAction__`; +/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketUpdateAction` AS SELECT +/*!50001 CREATE VIEW `ticketUpdateAction__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `ticketWeekly` +-- Table structure for table `ticketWeekly` -- DROP TABLE IF EXISTS `ticketWeekly`; -/*!50001 DROP VIEW IF EXISTS `ticketWeekly`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ticketWeekly` ( + `ticketFk` int(11) NOT NULL AUTO_INCREMENT, + `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', + PRIMARY KEY (`ticketFk`), + CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=2397961 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ticketWeekly__` +-- + +DROP TABLE IF EXISTS `ticketWeekly__`; +/*!50001 DROP VIEW IF EXISTS `ticketWeekly__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `ticketWeekly` AS SELECT +/*!50001 CREATE VIEW `ticketWeekly__` AS SELECT 1 AS `ticketFk`, 1 AS `weekDay`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `ticket__` +-- + +DROP TABLE IF EXISTS `ticket__`; +/*!50001 DROP VIEW IF EXISTS `ticket__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticket__` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `warehouseFk`, + 1 AS `shipped`, + 1 AS `landed`, + 1 AS `nickname`, + 1 AS `refFk`, + 1 AS `addressFk`, + 1 AS `location`, + 1 AS `solution`, + 1 AS `routeFk`, + 1 AS `companyFk`, + 1 AS `agencyModeFk`, + 1 AS `priority`, + 1 AS `packages`, + 1 AS `isDeleted`, + 1 AS `created`, + 1 AS `zoneFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `ticketeToPreparePrepared` -- @@ -26717,7 +29556,8 @@ SET character_set_client = utf8; 1 AS `warehouse_id`, 1 AS `province_id`, 1 AS `picked`, - 1 AS `trabajador`*/; + 1 AS `trabajador`, + 1 AS `sectorFk`*/; SET character_set_client = @saved_cs_client; -- @@ -26790,8 +29630,8 @@ CREATE TABLE `town` ( PRIMARY KEY (`id`), 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=108472 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `townProvinceFk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=241169 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 */ ; @@ -26805,12 +29645,8 @@ 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); + SET NEW.geoFk = zoneGeo_new('town', NEW.`name`, + (SELECT geoFk FROM province WHERE id = NEW.provinceFk)); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26826,11 +29662,11 @@ DELIMITER ; /*!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` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `town_beforeUpdate` BEFORE UPDATE ON `town` FOR EACH ROW BEGIN IF !(OLD.geoFk <=> NEW.geoFk) THEN - CALL zoneGeo_check; + CALL zoneGeo_throwNotEditable; END IF; END */;; DELIMITER ; @@ -26850,19 +29686,15 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`town_afterUpdate` AFTER UPDATE ON `town` FOR EACH ROW BEGIN - DECLARE vParentFk INT; - + IF !(OLD.provinceFk <=> NEW.provinceFk) THEN + CALL zoneGeo_setParent(NEW.geoFk, + (SELECT geoFk FROM province WHERE id = NEW.provinceFk)); + END IF; + 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 */ ; @@ -26928,7 +29760,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=342 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB AUTO_INCREMENT=434 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 */; -- @@ -26978,9 +29810,9 @@ CREATE TABLE `travel` ( KEY `travel_ibfk_4_idx` (`cargoSupplierFk`), CONSTRAINT `travel_ibfk_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, 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_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn2008`.`Proveedores_cargueras` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=137924 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=138681 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 */ ; @@ -27246,19 +30078,14 @@ SET character_set_client = utf8; /*!50001 CREATE VIEW `warehouse` AS SELECT 1 AS `id`, 1 AS `name`, - 1 AS `isFeedStock`, - 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 `isFeedStock`, 1 AS `isComparative`, - 1 AS `valuatedInventory`, + 1 AS `hasComission`, + 1 AS `hasAvailable`, 1 AS `isManaged`, - 1 AS `hasConfectionTeam`*/; + 1 AS `isForTicket`, + 1 AS `hasStowaway`*/; SET character_set_client = @saved_cs_client; -- @@ -27428,7 +30255,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12067 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12433 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27493,7 +30320,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=47892616 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=51536010 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27532,7 +30359,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=13471 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14891 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27590,12 +30417,13 @@ CREATE TABLE `workerTimeControl` ( `manual` tinyint(4) NOT NULL DEFAULT '0', `order` int(11) DEFAULT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `direction` enum('in','out','middle') COLLATE utf8_unicode_ci DEFAULT 'middle', PRIMARY KEY (`id`), UNIQUE KEY `userFk_Timed_uniq` (`userFk`,`timed`), 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=7713879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=8262896 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27615,6 +30443,24 @@ CREATE TABLE `workerTimeControlConfig` ( ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerTimeControlParams` +-- + +DROP TABLE IF EXISTS `workerTimeControlParams`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerTimeControlParams` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dayBreak` int(11) NOT NULL, + `weekBreak` int(11) NOT NULL, + `weekScope` int(11) NOT NULL, + `dayWorkMax` int(11) NOT NULL, + `dayStayMax` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerTimeControlPin` -- @@ -27660,6 +30506,7 @@ SET character_set_client = utf8; 1 AS `user`, 1 AS `password`, 1 AS `bcryptPassword`, + 1 AS `departmentFk`, 1 AS `dni`*/; SET character_set_client = @saved_cs_client; @@ -27915,8 +30762,8 @@ CREATE TABLE `zone` ( KEY `fk_zone_2_idx` (`agencyModeFk`), 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=411 DEFAULT CHARSET=utf8; + CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=444 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27958,8 +30805,48 @@ CREATE TABLE `zoneGeo` ( KEY `name_idx` (`name`), KEY `parentFk` (`parentFk`), KEY `path` (`path`) -) ENGINE=InnoDB AUTO_INCREMENT=110112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=597452 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`.`zoneGeo_beforeInsert` + BEFORE INSERT ON `zoneGeo` FOR EACH ROW +BEGIN + CALL zoneGeo_checkName(NEW.`name`); +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`.`zoneGeo_beforeUpdate` + BEFORE UPDATE ON `zoneGeo` FOR EACH ROW +BEGIN + IF !(OLD.`name` <=> NEW.`name`) THEN + CALL zoneGeo_checkName(NEW.`name`); + 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 `zoneGeoRecalc` @@ -27993,22 +30880,6 @@ 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' -- @@ -28155,7 +31026,7 @@ DELIMITER ;; /*!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 */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE ENABLE 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 */ ;; @@ -28420,6 +31291,101 @@ 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 `catalog_componentReverse` */; +/*!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 `catalog_componentReverse`(vWarehouse INT, + vCost DECIMAL(10,3), + vM3 DECIMAL(10,3), + vAddressFk INT, + vZoneFk INT) RETURNS decimal(10,3) + DETERMINISTIC +BEGIN + /* Calcula los componentes para un cliente a partir de un coste y volumen + * @param vWarehouse + * @param vCost Valor de coste del articulo + * @param vM3 m3 del articulo + * @param vAddressFk + * @param vZoneFk + * @param vRetailedPrice precio de venta sin iva + * @return tmp.catalog_component (warehouse_id, item_id, component_id, cost) + */ + + DECLARE vBoxVolume BIGINT; + DECLARE vCustomer INT; + DECLARE vComponentRecovery INT DEFAULT 17; + DECLARE vComponentMana INT DEFAULT 39; + DECLARE vDeliveryComponent INT DEFAULT 15; + DECLARE vComponentMargin INT DEFAULT 29; + DECLARE vComponentCost INT DEFAULT 28; + DECLARE vCost DECIMAL(10,2); + DECLARE vRetailedPrice DECIMAL(10,2); + DECLARE vItem INT DEFAULT 98; + + SELECT volume INTO vBoxVolume + FROM vn.packaging + WHERE id = '94'; + + SELECT clientFk INTO vCustomer FROM address WHERE id = vAddressFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.catalog_component; + CREATE TEMPORARY TABLE tmp.catalog_component LIKE + vn2008.template_catalog_component; + + -- Margen + INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + SELECT vWarehouse, vItem, vComponentMargin, vCost / (100 - rate2) + FROM vn.rate + WHERE dated <= CURDATE() + AND warehouseFk = vWarehouse + ORDER BY dated DESC + LIMIT 1; + + -- Recobro + INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + SELECT vWarehouse, vItem, vComponentRecovery, ROUND(LEAST(recobro,0.25), 3) + FROM bi.claims_ratio + WHERE Id_Cliente = vCustomer AND recobro > 0.009; + + -- Componente de maná automático, en función del maná acumulado por el comercial. + INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + SELECT vWarehouse, vItem, vComponentMana, ROUND(prices_modifier_rate, 3) + FROM client c + JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador + WHERE ms.prices_modifier_activated AND c.id = vCustomer LIMIT 1; + + -- Reparto + INSERT INTO tmp.catalog_component (warehouse_id, item_id, component_id, cost) + SELECT vWarehouse, vItem, vDeliveryComponent, + ROUND( + vM3 + * (z.price - z.bonus) + * z.inflation + / vBoxVolume, 4 + ) + FROM zone z + WHERE z.id = vZoneFk; + + -- Precio de venta + SELECT SUM(cost) INTO vRetailedPrice + FROM tmp.catalog_component; + + DROP TEMPORARY TABLE tmp.catalog_component; + RETURN vRetailedPrice; + +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 `clientGetDebt` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -29840,19 +32806,23 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `itemPacking`(vBarcode VARCHAR(22), vWarehouseFk INT) RETURNS int(11) + DETERMINISTIC BEGIN DECLARE vPacking INTEGER DEFAULT 0; DECLARE vItemFk INTEGER; + SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; + SELECT IFNULL(packing,0) INTO vPacking FROM vn.buy WHERE id = CAST(vBarcode AS DECIMAL(18,0)); + + + IF NOT vPacking THEN - - SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - + CALL cache.last_buy_refresh(FALSE); SELECT IFNULL(packing,1) INTO vPacking FROM (SELECT packing , created @@ -30111,6 +33081,32 @@ 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 `nz` */; +/*!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 `nz`(vQuantity DOUBLE) RETURNS double + DETERMINISTIC +BEGIN + + DECLARE vResult DOUBLE; + + SET vResult = IFNULL(vQuantity,0); + + RETURN vResult; + +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 `orderTotalVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30495,6 +33491,82 @@ 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 `timeWorkerControl_getDirection` */; +/*!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 `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8 COLLATE utf8_unicode_ci + READS SQL DATA +BEGIN +/** + * Verifica la dirección de la fichada + * @param vUserFk Identificador del trabajador + * @param vTimed Hora de la fichada + * @return Retorna sentido de la fichada 'in, out, middle' + */ + + DECLARE vPrevious DATETIME ; + DECLARE vNext DATETIME ; + DECLARE vPreviousDirection VARCHAR(3) ; + DECLARE vNextDirection VARCHAR(3) ; + DECLARE vDayStayMax INT; + DECLARE vTimedSeconds INT; + DECLARE vLastTimeIn INT; + + SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds; + + SELECT dayStayMax INTO vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT timed, direction INTO vNext,vNextDirection + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction IN ('in','out') + AND timed > vTimed + ORDER BY timed ASC + LIMIT 1; + + SELECT timed, direction INTO vPrevious, vPreviousDirection + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction IN ('in','out') + AND timed < vTimed + ORDER BY timed DESC + LIMIT 1; + + IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN + RETURN 'middle'; + END IF; + + + IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN + IF vPreviousDirection = 'in' THEN + RETURN 'out'; + ELSE + SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction ='in' + AND timed < vPrevious; + IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN + RETURN 'out'; + END IF; + END IF; + END IF; + + RETURN 'in'; +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 `workerIsBoss` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30566,6 +33638,15 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) NO SQL BEGIN +/** + * Creates a new node a node from the #zoneGeo table. + * Also sets a mark to force the tree recalculation. + * + * @param vType The node type + * @param vName The node name + * @param vParentFk The parent node identifier + * @return The new node identifier + */ DECLARE vSelf INT; INSERT INTO zoneGeo @@ -30658,17 +33739,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 `agencyHourGetAgencyKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetAgency__` */; /*!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 `agencyHourGetAgencyKk`(vAddress INT, vDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourGetAgency__`(vAddress INT, vDate DATE) BEGIN /** * DEPRECATED usar zoneGetAgency @@ -30830,17 +33911,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 `agencyHourGetShippedKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetShipped__` */; /*!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 `agencyHourGetShippedKk`(vLanded DATE, vAddressFk INT, vAgencyFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `agencyHourGetShipped__`(vLanded DATE, vAddressFk INT, vAgencyFk INT) BEGIN /** * DEPRECATED usar zoneGetShipped @@ -31332,6 +34413,215 @@ BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Grouping cannot be zero'; 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 `camaraFutureVolume` */; +/*!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 `camaraFutureVolume`(vWarehouseFk INT, vDateStart DATE, vDateEnd DATE) +BEGIN + + DECLARE vDated DATE; + DECLARE vSectorVolume INT; + DECLARE vLastDayVolume INT; + DECLARE vMinCamara INT; + + SET vDated = vDateStart; + + DROP TEMPORARY TABLE IF EXISTS tmp.camara; + + IF vDateStart = CURDATE() THEN + + CREATE TEMPORARY TABLE tmp.camara + SELECT vDated as dated, + CONCAT('sector ', sectorFk) as place, + FLOOR(SUM(ish.visible * r.cm3)/1000000) as m3 + FROM vn.itemShelving ish + JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = vWarehouseFk + 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 = vWarehouseFk + GROUP BY p.sectorFk; + + SELECT m3 + INTO vSectorVolume + FROM tmp.camara + WHERE place LIKE 'sector%'; + + CALL cache.visible_refresh(@calc_id, FALSE, 1); + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'nicho', + FLOOR((SUM(v.visible * r.cm3) / 1000000) - vSectorVolume ) as m3 + FROM cache.visible v + JOIN bi.rotacion r ON r.Id_Article = v.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = v.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE calc_id = @calc_id + AND ic.merchandise; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_in iei + JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = iei.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND NOT received + AND NOT isVirtualStock + AND iei.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_out ieo + JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = ieo.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND NOT delivered + AND NOT isVirtualStock + AND ieo.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_out io + JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = io.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.ticketStateToday tst ON tst.ticket = io.ticketFk + JOIN vn.ticket t ON t.id = io.ticketFk + WHERE ic.merchandise + AND ic.id != 7 + AND t.clientFk NOT IN (200,400,50,450) + AND dat BETWEEN vDated AND util.dayend(vDated) + AND NOT tst.isPicked + AND io.warehouse_id = vWarehouseFk; + + ELSE + + CREATE TEMPORARY TABLE tmp.camara + SELECT vDated as dated, + 'entradas' as place, + FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_in iei + JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = iei.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND NOT isVirtualStock + AND iei.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_out ieo + JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = ieo.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND ieo.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_out io + JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = io.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.ticket t ON t.id = io.ticketFk + WHERE ic.merchandise + AND dat BETWEEN vDated AND util.dayend(vDated) + AND ic.id != 7 + AND t.clientFk NOT IN (200,400,50,450) + AND io.warehouse_id = vWarehouseFk; + + END IF; + + -- Resto de dias + WHILE vDated < vDateEnd DO + + SELECT SUM(IFNULL(m3,0)) INTO vLastDayVolume + FROM tmp.camara + WHERE dated = vDated; + + SET vDated = TIMESTAMPADD(DAY, 1, vDated); + + INSERT INTO tmp.camara(dated, place, m3) + VALUES( vDated, 'camara', vLastDayVolume); + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'entradas', FLOOR(SUM(iei.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_in iei + JOIN bi.rotacion r ON r.Id_Article = iei.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = iei.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND NOT isVirtualStock + AND iei.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'salidas', FLOOR(SUM(ieo.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_entry_out ieo + JOIN bi.rotacion r ON r.Id_Article = ieo.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = ieo.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + WHERE ic.merchandise + AND dat = vDated + AND ieo.warehouse_id = vWarehouseFk; + + INSERT INTO tmp.camara(dated, place, m3) + SELECT vDated, 'ventas', FLOOR(SUM(io.amount * r.cm3) / 1000000) as m3 + FROM vn2008.item_out io + JOIN bi.rotacion r ON r.Id_Article = io.item_id AND r.warehouse_id = vWarehouseFk + JOIN vn.item i ON i.id = io.item_id + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.itemCategory ic ON ic.id = it.categoryFk + JOIN vn.ticket t ON t.id = io.ticketFk + WHERE ic.merchandise + AND dat BETWEEN vDated AND util.dayend(vDated) + AND ic.id != 7 + AND t.clientFk NOT IN (200,400,50,450) + AND io.warehouse_id = vWarehouseFk; + + END WHILE; + + SELECT min(m3) INTO vMinCamara + FROM + (SELECT dated, sum(m3) m3 + FROM tmp.camara + GROUP BY dated) sub; + + UPDATE tmp.camara + SET m3 = m3 - vMinCamara + WHERE place = 'camara'; + + SELECT camara.* FROM tmp.camara; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31443,6 +34733,132 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `catalog_calculate` */; +/*!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_calculate`( + vLanded DATE, + vAddressFk INT, + vAgencyModeFk INT) +proc: BEGIN +/** + * Calcula los articulos disponibles y sus precios + * + * @table tmp.item(itemFk) Listado de artículos a calcular + * @param vLanded Fecha de recepcion de mercancia + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.ticketCalculateItem(itemFk, available, producer, + * item, size, stems, category, inkFk, image, origin, price) + * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) + * @return tmp.ticketComponent + * @return tmp.ticketComponentPrice + * @return tmp.zoneGetShipped + + **/ + + DECLARE vAvailableCalc INT; + DECLARE vShipped DATE; + DECLARE vClient INT; + DECLARE vWarehouseFk SMALLINT; + DECLARE vZoneFk INT; + DECLARE vDone BOOL; + DECLARE cTravelTree CURSOR FOR + SELECT id, warehouseFk, shipped FROM tmp.zoneGetShipped; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + -- Establece los almacenes y las fechas que van a entrar al disponible + + SELECT clientFk INTO vClient + FROM address WHERE id = vAddressFk; + + CALL vn.zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; + CREATE TEMPORARY TABLE tmp.ticketLot( + `warehouseFk` smallint(5) unsigned NOT NULL, + `itemFk` int(11) NOT NULL, + `available` double DEFAULT NULL, + `buyFk` int(11) DEFAULT NULL, + `fix` tinyint(3) unsigned DEFAULT '0', + KEY `itemFk` (`itemFk`), + KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH + ) ENGINE=MEMORY DEFAULT CHARSET=utf8; + + OPEN cTravelTree; + + l: LOOP + SET vDone = FALSE; + FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; + + IF vDone THEN + LEAVE l; + END IF; + + CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL buyUltimate (vWarehouseFk, vShipped); + + INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk) + SELECT vWarehouseFk, + i.item_id, + IFNULL(i.available, 0), + bu.buyFk + FROM `cache`.available i + JOIN tmp.item br ON br.itemFk = i.item_id + LEFT JOIN item it ON it.id = i.item_id + LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id + WHERE i.calc_id = vAvailableCalc + AND it.id != 100 + AND i.available > 0; + + DROP TEMPORARY TABLE tmp.buyUltimate; + END LOOP; + + CLOSE cTravelTree; + + CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; + CREATE TEMPORARY TABLE tmp.ticketCalculateItem + ENGINE = MEMORY + SELECT + b.itemFk, + SUM(b.available) available, + p.name producer, + i.name item, + i.size size, + i.stems, + i.category, + i.inkFk, + i.image, + o.code origin, + bl.price, + bl.priceKg + FROM tmp.ticketLot b + JOIN item i ON b.itemFk = i.id + LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible + JOIN origin o ON o.id = i.originFk + JOIN ( + SELECT MIN(price) price, itemFk, MIN(priceKg) priceKg + FROM tmp.ticketComponentPrice + GROUP BY itemFk + ) bl ON bl.itemFk = b.itemFk + GROUP BY b.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 `catalog_componentCalculate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -31484,8 +34900,7 @@ proc: BEGIN 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'; @@ -31511,7 +34926,7 @@ proc: BEGIN ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, tl.buyFk, i.typeFk, - IF(i.hasKgPrice,(b.packing * b.weight) / 1000, NULL) weightPacking + IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping FROM tmp.ticketLot tl JOIN buy b ON b.id = tl.buyFk JOIN item i ON i.id = tl.itemFk @@ -31654,7 +35069,7 @@ proc: BEGIN 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 + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -31669,7 +35084,7 @@ proc: BEGIN 2 rate, tcc.packing grouping, SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg + SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -31684,7 +35099,7 @@ proc: BEGIN 3 rate, tcc.available grouping, SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg + SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -31999,7 +35414,7 @@ BEGIN DELETE FROM vn.messageInbox WHERE sendDate < vDateShort; DELETE FROM vn.workerTimeControl WHERE timed < fourYearsAgo; DELETE FROM vn.itemShelving WHERE created < CURDATE() AND visible = 0; - + DELETE FROM vn.ticketDown WHERE created < TIMESTAMPADD(DAY,-1,CURDATE()); CALL shelving_clean; CALL vn.ticketPackagingRecovery; @@ -32717,9 +36132,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -32761,7 +36176,11 @@ BEGIN WHILE NOT done DO INSERT INTO tmp.contador SET id = vClientFk; CALL vn.clientGreugeSpray(vClientFk, TRUE, '',TRUE); - UPDATE vn.client SET salesPersonFk = NULL WHERE id = vClientFk; + UPDATE vn.client SET salesPersonFk = NULL WHERE id = vClientFk; + + INSERT INTO vn.clientLog (originFk, userFk, `action`, description) + VALUES (vClientFk, account.userGetId(), 'update', CONCAT('Se ha desasignado el cliente por que no ha comprado en 3 meses')); + REPLACE bs.clientNewBorn(clientFk, shipped) VALUES(vClientFk, CURDATE()); FETCH rs INTO vClientFk; @@ -33363,6 +36782,132 @@ 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 `department_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 `department_calcTree`() +BEGIN +/** + * Calculates the #path, #lft, #rgt, #sons and #depth columns of + * the #department table. To build the tree, it uses the #parentFk + * column. + */ + DECLARE vIndex INT DEFAULT 0; + DECLARE vSons INT; + + DROP TEMPORARY TABLE IF EXISTS tNestedTree; + CREATE TEMPORARY TABLE tNestedTree + SELECT id, path, lft, rgt, depth, sons + FROM department LIMIT 0; + + SET max_sp_recursion_depth = 5; + CALL department_calcTreeRec(NULL, '/', 0, vIndex, vSons); + SET max_sp_recursion_depth = 0; + + UPDATE department z + JOIN tNestedTree t ON t.id = z.id + SET z.path = t.path, + z.lft = t.lft, + z.rgt = t.rgt, + z.depth = t.depth, + z.sons = t.sons; + + DROP TEMPORARY TABLE tNestedTree; +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 `department_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 `department_calcTreeRec`( + vSelf INT, + vPath VARCHAR(255), + vDepth INT, + INOUT vIndex INT, + OUT vSons INT +) +BEGIN +/** + * Calculates and sets the #path, #lft, #rgt, #sons and #depth + * columns for all children of the passed node. Once calculated + * the last node rgt index and the number of sons are returned. + * To update it's children, this procedure calls itself recursively + * for each one. + * + * @vSelf The node identifier + * @vPath The initial path + * @vDepth The initial depth + * @vIndex The initial lft index + * @vSons The number of direct sons + */ + DECLARE vChildFk INT; + DECLARE vLft INT; + DECLARE vMySons INT; + DECLARE vDone BOOL; + DECLARE vChildren CURSOR FOR + SELECT id FROM department + WHERE (vSelf IS NULL AND parentFk IS NULL) + OR (vSelf IS NOT NULL AND parentFk = vSelf); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SET vSons = 0; + + OPEN vChildren; + myLoop: LOOP + SET vDone = FALSE; + FETCH vChildren INTO vChildFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + SET vIndex = vIndex + 1; + SET vLft = vIndex; + SET vSons = vSons + 1; + + CALL department_calcTreeRec( + vChildFk, + CONCAT(vPath, vChildFk, '/'), + vDepth + 1, + vIndex, + vMySons + ); + + SET vIndex = vIndex + 1; + + INSERT INTO tNestedTree + SET id = vChildFk, + path = vPath, + lft = vLft, + rgt = vIndex, + depth = vDepth, + sons = vMySons; + END LOOP; + CLOSE vChildren; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `duaEntryValueUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35156,7 +38701,6 @@ BEGIN DECLARE vRate DECIMAL(10,4); DECLARE vSerial VARCHAR(2); - CALL invoiceInBookingCommon(vInvoiceInId,vSerialNumber); SELECT serial @@ -35258,167 +38802,164 @@ BEGIN WHERE iit.expenceFk != 5660000002 GROUP BY iit.expenceFk; - - -- -------------------------------------------------------------------- - -- ------- Lineas de IVA --------------- - -- -------------------------------------------------------------------- - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - FECREGCON, - empresa_id - ) - SELECT vBookNumber ASIEN, - n.bookEntried FECHA, - tc.code SUBCTA, - s.supplierAccount CONTRA, - SUM(ROUND(tc.rate/100*it.taxableBase + 0.0001,2)) EURODEBE, - SUM(it.taxableBase) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - tc.rate IVA, - IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, - n.serial SERIE, - tt.TIPOOPE, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, - TRUE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, - n.cplusTrascendency472Fk TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.booked FECREGCON, - n.companyFk + -- -------------------------------------------------------------------- + -- ------- Lineas de IVA --------------- + -- -------------------------------------------------------------------- - FROM newInvoiceIn n + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + FECREGCON, + empresa_id + ) + SELECT vBookNumber ASIEN, + n.bookEntried FECHA, + tc.code SUBCTA, + s.supplierAccount CONTRA, + SUM(ROUND(tc.rate/100*it.taxableBase + 0.0001,2)) EURODEBE, + SUM(it.taxableBase) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tc.rate IVA, + IF(isUeeMember AND eWithheld.id IS NULL,'','*') AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + TRUE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + n.cplusTrascendency472Fk TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.booked FECREGCON, + n.companyFk + + FROM newInvoiceIn n + JOIN newSupplier s + JOIN invoiceInTax it ON n.id = it.invoiceInFk + JOIN taxCode tc ON tc.id = it.taxCodeFk + JOIN taxType tt ON tt.id = tc.taxTypeFk + JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk + LEFT JOIN + (SELECT eWithheld.id + FROM invoiceInTax hold + JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld + WHERE hold.invoiceInFk = 58262 LIMIT 1 + ) eWithheld ON TRUE + WHERE tc.type != '-' + AND tc.isActive + GROUP BY tc.rate; + + -- Linea iva inversor sujeto pasivo + + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id + ) + + SELECT + vBookNumber ASIEN, + n.bookEntried FECHA, + tcLink.code SUBCTA, + s.supplierAccount CONTRA, + ROUND(tcLink.rate/100*SUM(it.taxableBase) + 0.0001,2) EUROHABER, + ROUND(SUM(it.taxableBase),2) BASEEURO, + GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, + vSerialNumber FACTURA, + tcLink.rate IVA, + '*' AUXILIAR, + n.serial SERIE, + tt.TIPOOPE, + n.issued FECHA_EX, + n.operated FECHA_OP, + n.invoicesCount NFACTICK, + n.supplierRef FACTURAEX, + FALSE L340, + (isSameCountry OR NOT isUeeMember) LRECT349, + 1 TIPOCLAVE, + n.cplusTaxBreakFk TIPOEXENCI, + n.cplusSubjectOpFk TIPONOSUJE, + n.cplusInvoiceType472Fk TIPOFACT, + n.cplusRectificationTypeFk TIPORECTIF, + iis.cplusTerIdNifFk TERIDNIF, + s.nif AS TERNIF, + s.name AS TERNOM, + n.companyFk + + FROM newInvoiceIn n JOIN newSupplier s JOIN invoiceInTax it ON n.id = it.invoiceInFk JOIN taxCode tc ON tc.id = it.taxCodeFk JOIN taxType tt ON tt.id = tc.taxTypeFk JOIN invoiceInSerial iis ON iis.code = tt.serial + JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id AND tc.link JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk - LEFT JOIN - (SELECT eWithheld.id - FROM invoiceInTax hold - JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld - WHERE hold.invoiceInFk = 58262 LIMIT 1 - ) eWithheld ON TRUE - WHERE tc.type != '-' - AND tc.isActive - GROUP BY tc.rate; - - -- Linea iva inversor sujeto pasivo - - INSERT INTO vn2008.XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id - ) - - SELECT - vBookNumber ASIEN, - n.bookEntried FECHA, - tcLink.code SUBCTA, - s.supplierAccount CONTRA, - ROUND(tcLink.rate/100*SUM(it.taxableBase) + 0.0001,2) EUROHABER, - ROUND(SUM(it.taxableBase),2) BASEEURO, - GROUP_CONCAT(DISTINCT e.`name` SEPARATOR ', ') CONCEPTO, - vSerialNumber FACTURA, - tcLink.rate IVA, - '*' AUXILIAR, - n.serial SERIE, - tt.TIPOOPE, - n.issued FECHA_EX, - n.operated FECHA_OP, - n.invoicesCount NFACTICK, - n.supplierRef FACTURAEX, - FALSE L340, - (isSameCountry OR NOT isUeeMember) LRECT349, - 1 TIPOCLAVE, - n.cplusTaxBreakFk TIPOEXENCI, - n.cplusSubjectOpFk TIPONOSUJE, - n.cplusInvoiceType472Fk TIPOFACT, - n.cplusRectificationTypeFk TIPORECTIF, - iis.cplusTerIdNifFk TERIDNIF, - s.nif AS TERNIF, - s.name AS TERNOM, - n.companyFk - - FROM newInvoiceIn n - JOIN newSupplier s - JOIN invoiceInTax it ON n.id = it.invoiceInFk - JOIN taxCode tc ON tc.id = it.taxCodeFk - JOIN taxType tt ON tt.id = tc.taxTypeFk - JOIN invoiceInSerial iis ON iis.code = tt.serial - JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id AND tc.link - JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk - WHERE tc.isActive - AND (tc.type = 'S' OR MID(s.supplierAccount,4,1) = '1') - GROUP BY tcLink.rate, e.id; - - - --- Actualización del registro original + WHERE tc.isActive + AND (tc.type = 'S' OR MID(s.supplierAccount,4,1) = '1') + GROUP BY tcLink.rate, e.id; + + -- Actualización del registro original UPDATE invoiceIn ii JOIN newInvoiceIn ni ON ii.id = ni.id - SET - ii.serialNumber = vSerialNumber, + SET ii.serialNumber = vSerialNumber, ii.isBooked = TRUE; UPDATE vn.config @@ -35474,17 +39015,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 `invoiceMakeByClientKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceMakeByClient__` */; /*!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 `invoiceMakeByClientKk`(vClientFk INT, vSerial CHAR(1), vShipped DATE, vCompanyFk INT, OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceMakeByClient__`(vClientFk INT, vSerial CHAR(1), vShipped DATE, vCompanyFk INT, OUT vInvoiceId INT) BEGIN /** * Factura un ticket @@ -35505,17 +39046,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 `invoiceMakeByTicketKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceMakeByTicket__` */; /*!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 `invoiceMakeByTicketKk`(vTicketFk INT, vSerial CHAR(1), OUT vInvoiceId INT) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceMakeByTicket__`(vTicketFk INT, vSerial CHAR(1), OUT vInvoiceId INT) BEGIN /** OBSOLETO USAR invoiceOut_newFromTicket * Factura un ticket @@ -35606,17 +39147,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 `invoiceOutAgainDateRangeKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `invoiceOutAgainDateRange__` */; /*!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 `invoiceOutAgainDateRangeKk`(IN vFirstDate DATE, IN vLastDate DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOutAgainDateRange__`(IN vFirstDate DATE, IN vLastDate DATE) BEGIN DECLARE done BOOL DEFAULT FALSE; @@ -37165,7 +40706,7 @@ BEGIN ish.stock, LEAST(ish.stock,quantity) as total, CONCAT( - CAST(LEAST(ish.stock,quantity) / ish.packing AS DECIMAL(10,0)), + CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)), ' x ', ish.packing, IF ( @@ -37219,7 +40760,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyGetOrder`() +CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyGetOrder`(vSector INT ) BEGIN DECLARE vId INT; @@ -37228,6 +40769,7 @@ BEGIN FROM vn.itemPlacementSupplyList ipsl WHERE Saldo > 0 AND (repoUserFk is NULL OR repoUserFk = getUser()) + AND ipsl.sectorFk = vSector ORDER BY priority DESC, parking DESC, created LIMIT 1; @@ -37254,16 +40796,17 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) BEGIN SELECT shelving, parking, sum(stock) as stockTotal,created FROM ( - SELECT * - FROM vn.itemShelvingPlacementSupplyStock - WHERE itemFk = vItemFk - ORDER BY priority DESC, created + SELECT * + FROM vn.itemShelvingPlacementSupplyStock + LEFT JOIN vn.parking p ON p.code = parking + WHERE itemFk = vItemFk AND p.sectorFk = vSectorFk + ORDER BY priority DESC, created ) sub GROUP BY shelving; @@ -37877,24 +41420,30 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingMatch`(vEntryFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingMatch`(vEntryFk INT, vAllTravel BOOLEAN, vFromTimed DATETIME, vToTimed DATETIME) BEGIN - SELECT i.id, i.longName, i.size, i.subName, b.stickers, ish.etiquetas + DECLARE vTravelFk INT; + + SELECT travelFk INTO vTravelFk + FROM entry + WHERE id = vEntryFk; + + SELECT i.id, i.longName, i.size, i.subName, b.stickers, ish.etiquetas, b.printed FROM item i - LEFT JOIN ( - SELECT itemFk, sum(stickers) AS stickers - FROM buy - WHERE entryFk = vEntryFk + JOIN ( + SELECT itemFk, sum(stickers) AS stickers, sum(printedStickers) as printed + FROM buy b + JOIN entry e ON e.id = b.entryFk + WHERE IF(vAllTravel , travelFk = vTravelFk, b.entryFk = vEntryFk) GROUP BY itemFk ) b ON b.itemFk = i.id LEFT JOIN ( - SELECT itemFk, sum(cast(quantity / packing AS DECIMAL(10,0))) AS etiquetas + SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas FROM itemShelving ish JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN parking pk ON pk.id = sh.parkingFk - WHERE created > CURDATE() - AND IFNULL(pk.`column`,0) < 700 + WHERE ish.created BETWEEN vFromTimed AND vToTimed GROUP BY itemFk ) ish ON ish.itemFk = id WHERE b.stickers OR ish.etiquetas; @@ -37985,7 +41534,7 @@ BEGIN WHERE saldo > 0 AND sectorFk = vSectorFk GROUP BY itemFk) sub3 ON sub3.itemFk = i.id - WHERE v.visible - GREATEST(0,iss.visible) < s.quantity + WHERE v.visible + IFNULL(sub3.transit,0) - GREATEST(0,iss.visible) < s.quantity AND IFNULL(sub3.transit,0) < s.quantity AND s.isPicked = FALSE AND s.reserved = FALSE @@ -37996,61 +41545,6 @@ BEGIN 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; - - CALL cache.visible_refresh (vVisibleCache, FALSE, 1); - - 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 - 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 util.dayend(CURDATE()) - AND tst.productionOrder < 6 - AND t.warehouseFk = vWarehouseFk - AND mm.Id_Movimiento IS NULL - ORDER BY itemFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38069,7 +41563,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingRadar`(vSectorFk INT) BEGIN - DECLARE vWarehouseFk INT; DECLARE vCalcVisibleFk INT; DECLARE vCalcAvailableFk INT; @@ -38078,153 +41571,81 @@ BEGIN FROM vn.sector WHERE id = vSectorFk; - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 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; + CREATE TEMPORARY TABLE tmp.itemShelvingRadar + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT iss.itemFk, + 0 `hour`, + 0 `minute`, + ip.`code` itemPlacementCode, + i.longName, + i.size, + i.subName producer, + i.upToDown, + a.available, + IFNULL(v.visible,0) - IFNULL(iss.visible,0) dayEndVisible, + IFNULL(v.visible,0) - IFNULL(iss.visible,0) firstNegative, + IFNULL(v.visible,0) - IFNULL(iss.visible,0) itemPlacementVisible, + i.minimum * b.packing itemPlacementSize, + ips.onTheWay, + iss.visible itemShelvingStock, + IFNULL(v.visible,0) visible + FROM vn.itemShelvingStock iss + JOIN vn.item i on i.id = iss.itemFk + LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iss.itemFk AND ip.warehouseFk = vWarehouseFk + LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk + LEFT JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay + FROM vn.itemPlacementSupplyList + WHERE saldo > 0 + GROUP BY itemFk + ) ips ON ips.itemFk = i.id + WHERE iss.sectorFk =vSectorFk ; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; + CREATE TEMPORARY TABLE tmp.itemOutTime + SELECT *,SUM(amount) quantity + FROM + (SELECT item_id itemFk, + amount, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes + FROM vn2008.item_out io + JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.item_id + JOIN vn.ticket t on t.id= io.ticketFk + JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk + JOIN vn.state s ON s.id = ts.stateFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + WHERE st.created > CURDATE() + AND st.isChecked + ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk + WHERE t.warehouseFk = vWarehouseFk + AND s.isPicked = 0 + AND NOT io.Reservado + AND stPrevious.saleFk IS NULL + AND io.dat >= CURDATE() + AND io.dat < CURDATE()+1 + ) sub + GROUP BY itemFk, hours, minutes; + + INSERT INTO tmp.itemShelvingRadar (itemFk) + SELECT itemFk FROM tmp.itemOutTime + ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, + firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity), + `hour` = if (firstNegative > 0 , `hour`, hours), + `minute` = if (firstNegative > 0, `minute`, minutes); + + SELECT * FROM tmp.itemShelvingRadar; + + DROP TEMPORARY TABLE tmp.itemShelvingRadar; END ;; DELIMITER ; @@ -38291,158 +41712,6 @@ BEGIN 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; - DECLARE vCalcAvailableFk INT; - - 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 - (INDEX (ticketFk)) ENGINE = MEMORY - 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 - (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 - - 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 - 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 - (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.ticketState; - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadarMin; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38652,7 +41921,7 @@ BEGIN END IF; INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount) - SELECT vTicketFk, vItemFk, CONCAT(vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)," " , longName), vVisible - vNewVisible,0,0 + SELECT vTicketFk, vItemFk, CONCAT(longName," ",vn.getWorkerCode(), " ",LEFT(CAST(NOW() AS TIME),5)), vVisible - vNewVisible,0,0 FROM vn.item WHERE id = vItemFk; @@ -38667,23 +41936,23 @@ 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 `itemTagArrangedUpdateKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemTagArrangedUpdate__` */; /*!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 `itemTagArrangedUpdateKk`(IN vItem BIGINT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemTagArrangedUpdate__`(IN vItem BIGINT) BEGIN /** * Actualiza la tabla itemTagArranged * * @param vItem El Id_item de toda la vida. Si es cero, equivale a todos. - **/ + */ DELETE FROM itemTagArranged WHERE vItem IS NULL @@ -39888,9 +43157,10 @@ BEGIN /* Clientes especiales: 3240 MADEFLOR 992 JAVIER FELIU + 4 TONI VENDRELL */ - IF vClient IN (992, 3240) THEN + IF vClient IN (992, 3240, 4) THEN SET vGraceDays = 365; @@ -39898,7 +43168,6 @@ BEGIN /* Fin clientes especiales */ - DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice; CREATE TEMPORARY TABLE tmp.packageToInvoice @@ -39911,8 +43180,7 @@ BEGIN JOIN packaging p ON p.id = tp.packagingFk JOIN ticket t ON t.id = tp.ticketFk WHERE t.shipped BETWEEN vDateStart AND vDate - AND t.clientFk = vClient - AND t.companyFk = vCompany; + AND t.clientFk = vClient; DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoicePositives; @@ -40009,9 +43277,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -40020,7 +43288,6 @@ BEGIN DECLARE valueFk INT; DECLARE encajando INT DEFAULT 9; - DECLARE accionEncajado INT DEFAULT 5; SELECT valor INTO valueFk FROM vn2008.Movimientos_mark @@ -40029,8 +43296,8 @@ BEGIN SET valueFk = (IFNULL(valueFk,0) + 1) MOD 3; - REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, Id_Accion, stateFk) - VALUES(saleFk,valueFk,getWorker(),accionEncajado,encajando); + REPLACE vn2008.Movimientos_mark(Id_Movimiento, valor, Id_Trabajador, stateFk) + VALUES(saleFk,valueFk,getWorker(),encajando); END ;; @@ -40049,7 +43316,82 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `payRoll`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `payRoll`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE, IN vFullDay BOOL) +BEGIN + + SET @userFk := 0; + + SELECT CONCAT(w.lastName,', ',w.firstname) AS Trabajador, + CAST(Sum((wj.total + wj.permission + wj.lunch)* wj.priceOrdinaryHour + wj.hollyday * wj.priceHollydayHour + + wj.nocturn * wj.priceNocturnHour + + wj.extra * wj.priceExtraHour) AS DECIMAL(10,2)) AS salario, + CAST(Sum(wj.permission) AS DECIMAL(10,2)) AS permission, + CAST(Sum(wj.total) AS DECIMAL(10,2)) AS total, + CAST(Sum(wj.nocturn) AS DECIMAL(10,2)) AS nocturn, + CAST(Sum(wj.hollyday) AS DECIMAL(10,2)) AS hollyday, + CAST(Sum(wj.lunch) AS DECIMAL(10,2)) AS lunch, + CAST(Sum(wj.extra) AS DECIMAL(10,2)) AS extra, + CAST(Sum(wj.contractJourney) AS DECIMAL(10,2)) AS contractJourney, + d.name AS departamento, + CAST(Sum((wj.contractJourney + wj.permission) * wj.priceOrdinaryHour) AS DECIMAL(10,2)) AS teorico, + CAST(Sum((wj.lunch + wj.permission + wj.total) * wj.priceordinaryhour) AS DECIMAL(10,2)) AS practico, + CAST(Sum(wj.nocturn * wj.pricenocturnhour) AS DECIMAL(10,2)) AS nocturno, + CAST(Sum(wj.hollyday * wj.priceHollydayHour) AS DECIMAL(10,2)) AS festivos, + CAST(Sum(wj.extra * wj.priceextrahour) AS DECIMAL(10,2)) AS extras, + MAX(wj.businessFk) as businessFk, + Min(b.date_start) AS fromDated, + Max(b.date_end) AS toDated, + blp.importepactado, + bl.porhoras, + IF(wj.userFk != @userFk, CAST(IFNULL(a.Anticipos,0) AS DECIMAL(10,2)), 0) AS Anticipos, + IF(wj.userFk != @userFk, CAST(IFNULL(se.SaldoEuros,0) AS DECIMAL(10,2)), 0) AS SaldoEuros, + @userFk := wj.userFk as userFk + + FROM vn.worker w + JOIN vn.workerJourney wj ON w.userFk = wj.userFk + JOIN postgresql.business_labour bl ON bl.business_id = wj.businessFk + JOIN postgresql.calendar_labour_type cl ON cl.calendar_labour_type_id = bl.calendar_labour_type_id + JOIN vn2008.department d ON bl.department_id = d.department_id + JOIN postgresql.business_labour_payroll blp ON bl.business_id = blp.business_id + JOIN postgresql.business b ON b.business_id = wj.businessFk + LEFT JOIN + (SELECT userFk, sum(debe) as Anticipos + FROM postgresql.income_employee ie + JOIN postgresql.person pe ON ie.person_id = pe.person_id + JOIN vn.worker w ON w.id = pe.id_trabajador + WHERE odbc_date BETWEEN vFromPaid AND vToPaid + AND id_incomeType = 14 -- Salario + GROUP BY userFk + ) a ON a.userFk = wj.userFk + LEFT JOIN + (SELECT userFk, sum(debe) - sum(haber) as SaldoEuros + FROM postgresql.income_employee ie + JOIN postgresql.person pe ON ie.person_id = pe.person_id + JOIN vn.worker w ON w.id = pe.id_trabajador + GROUP BY userFk + ) se ON se.userFk = wj.userFk + WHERE wj.dated BETWEEN vFromDated AND vToDated + AND IF(vFullDay,cl.hours_week <= 40,cl.hours_week < 40) + GROUP BY wj.userFk + ORDER BY w.lastName, w.firstname; + +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 `payRoll__` */; +/*!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 `payRoll__`(IN vFromDated DATE, IN vToDated DATE, IN vFromPaid DATE, IN vToPaid DATE) BEGIN SET @userFk := 0; @@ -40174,51 +43516,38 @@ DELIMITER ;; 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 0,999999,0 INTO @sameTicket, @ticket, @litrosTicket; + - 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.sectorProdPriority <= 3 - GROUP BY saleFk - HAVING isa.quantity <= totalAvailable; + SELECT @litrosTicket := IF(sub.ticketFk = @ticket, @litrosTicket + Litros, Litros) as LitrosTicket, + @sameTicket := IF(sub.ticketFk = @ticket, @sameTicket, IF(@sameTicket, 0 , 1)) as sameTicket, + sub.*, + @ticket := ticketFk + FROM + ( + SELECT * FROM + ( + 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, + CAST(isa.physicalVolume * 1000 AS DECIMAL(10,0)) as Litros + FROM vn.itemShelvingAvailable isa + JOIN vn.item i ON i.id = isa.itemFk + JOIN vn.sector s ON s.id = vSectorFk + WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) + AND isa.isPreviousPreparable = TRUE + AND isa.sectorFk = vSectorFk + AND isa.quantity > 0 + GROUP BY saleFk + HAVING isa.quantity <= totalAvailable + ) sub2 + ORDER BY Hora, Minuto, ticketFk + ) sub + ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41193,7 +44522,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `salePreparingList`(IN `idT` BIGINT) +CREATE DEFINER=`root`@`%` PROCEDURE `salePreparingList`(IN ticketFk BIGINT) BEGIN SELECT t.clientFk, @@ -41227,12 +44556,12 @@ BEGIN LEFT JOIN vn2008.cooler_path_detail cpd on left(ip.code,3) = cpd.pasillo LEFT JOIN bi.Last_buy_id lb ON lb.Id_Article = i.id AND lb.warehouse_id = t.warehouseFk LEFT JOIN vn.buy b ON b.id = lb.Id_Compra + LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26 LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 14 LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 8 - LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26 LEFT JOIN vn.itemBarcode ib ON ib.itemFk = i.id - WHERE t.id = idT + WHERE t.id = ticketFk GROUP BY s.id; END ;; @@ -41310,6 +44639,9 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) BEGIN + DELETE FROM itemShelvingSale + WHERE saleFk = vSaleFk; + DELETE st.* FROM vn.saleTracking st JOIN vn.state s @@ -41491,6 +44823,184 @@ BEGIN WHERE shelvingFk = vShelvingO 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 `shelvingFuture` */; +/*!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 `shelvingFuture`(vSectorFk INT) +BEGIN + + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vItemFk INT; + DECLARE vItemShelvingRest INT; + DECLARE vItemShelvingFk INT; + DECLARE vItemShelvingCreated DATE; + DECLARE vSaleRest INT; + DECLARE vSaleDated DATE; + DECLARE vWarehouseFk INT; + + DECLARE rsItem CURSOR FOR + SELECT DISTINCT itemFk + FROM vn.itemShelvingStock + WHERE sectorFk = vSectorFk + AND visible > 0; + + DECLARE rsItemShelving CURSOR FOR + SELECT ish.id, + ish.visible, + date(ish.created) + FROM vn.itemShelving ish + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE ish.itemFk = vItemFk + AND ish.visible > 0 + AND p.sectorFk = vSectorFk + ORDER BY date(ish.created), ish.visible; + + DECLARE rsSale CURSOR FOR + SELECT - floor(sum(io.amount)) as sold, + date(io.dat) as dated + FROM vn2008.item_out io + LEFT JOIN tmp.ticketFree tf ON tf.ticketFk = io.ticketFk + WHERE (dat BETWEEN util.tomorrow() AND '2019-10-31' + OR + (dat BETWEEN CURDATE() AND util.dayEnd(CURDATE()) AND tf.ticketFk IS NOT NULL)) + AND item_id = vItemFk + AND io.warehouse_id = vWarehouseFk + GROUP BY dated; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + SELECT warehouseFk INTO vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketFree; + CREATE TEMPORARY TABLE tmp.ticketFree + SELECT ticket as ticketFk + FROM vn.ticketStateToday tst + JOIN vn.state s ON s.id = tst.state + WHERE s.isPicked = FALSE; + + DROP TEMPORARY TABLE IF EXISTS tmp.result; + CREATE TEMPORARY TABLE tmp.result + SELECT ish.id as itemShelvingFk, + date(ish.created) as created, + ish.visible, + 0 as reserve, + '2019-10-31' as picked, + ish.shelvingFk, + 0 as Litros + FROM vn.itemShelving ish + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE ish.visible > 0 + AND p.sectorFk = vSectorFk + ORDER BY date(ish.created), ish.visible; + + UPDATE tmp.result r + JOIN (SELECT ish.id, floor(sum(ish.visible * r.cm3) / 1000) as Litros + FROM vn.itemShelving ish + JOIN bi.rotacion r ON r.Id_Article = ish.itemFk AND r.warehouse_id = vWarehouseFk + GROUP BY ish.id) sub ON r.itemShelvingFk = sub.id + SET r.Litros = sub.Litros; + + ALTER TABLE tmp.result + ADD PRIMARY KEY (itemShelvingFk); + + OPEN rsItem; + + FETCH rsItem INTO vItemFk; + + -- TRUNCATE tmp.log; + + WHILE NOT vDone DO + + OPEN rsItemShelving; + OPEN rsSale; + + FETCH rsSale INTO vSaleRest, vSaleDated; + FETCH rsItemShelving INTO vItemShelvingFk, vItemShelvingRest, vItemShelvingCreated; + /* + INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide) + VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '0'); + */ + bucle: LOOP + + IF vDone THEN + + LEAVE bucle; + + END IF; + + IF vSaleRest >= vItemShelvingRest THEN + /* + INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide) + VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '1'); + */ + SET vSaleRest = vSaleRest - vItemShelvingRest; + + UPDATE tmp.result + SET reserve = reserve + vItemShelvingRest, + picked = LEAST(picked, vSaleDated) + WHERE itemShelvingFk = vItemShelvingFk; + + FETCH rsItemShelving INTO vItemShelvingFk, vItemShelvingRest, vItemShelvingCreated; + + IF vSaleRest = 0 THEN + + FETCH rsSale INTO vSaleRest, vSaleDated; + + END IF; + + ELSE + /* + INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide) + VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '2'); + */ + SET vItemShelvingRest = vItemShelvingRest - vSaleRest; + + UPDATE tmp.result + SET reserve = reserve + vSaleRest, + picked = LEAST(picked, vSaleDated) + WHERE itemShelvingFk = vItemShelvingFk; + + FETCH rsSale INTO vSaleRest, vSaleDated; + + END IF; + + END LOOP; + + CLOSE rsItemShelving; + CLOSE rsSale; + /* + INSERT INTO tmp.log(vItemFk, vItemShelvingRest, vSaleRest, vSalePicked,ifSide) + VALUES (vItemFk, vItemShelvingRest, vSaleRest, vSaleDated, '4'); + */ + SET vDone = FALSE; + + FETCH rsItem INTO vItemFk; + + END WHILE; + + CLOSE rsItem; + + SELECT * FROM tmp.result + ORDER BY created, visible; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41541,7 +45051,157 @@ BEGIN IF length(vShelvingFk) > 6 THEN + REPLACE vn.ticketParking(ticketFk,parkingFk) + VALUES (vShelvingFk, vParkingFk); + -- deprecated: eliminar despues de campaña PAK 2019-10-08 + REPLACE vn.shelving(code, parkingFk, isPrinted, parked) + VALUES(vShelvingFk, vParkingFk, TRUE, NOW()); + -- fin deprecated + CALL vn.ticketStatePrevious(vShelvingFk); + + ELSE + + UPDATE vn.shelving + SET parkingFk = vParkingFk, parked = NOW() + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + SELECT (COUNT(*) > 0) AS IsUpdated + FROM vn.shelving + WHERE parkingFk = vParkingFk + AND `code` = vShelvingFk COLLATE utf8_unicode_ci; + + 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 `shelvingPark_Beta` */; +/*!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 `shelvingPark_Beta`(IN `vShelvingFk` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) +BEGIN + + DECLARE vParkingFk INT DEFAULT 0; + DECLARE idParking INT; + DECLARE vColumn VARCHAR(3); + DECLARE vRow VARCHAR(2); + DECLARE vReturn VARCHAR(50); + + /*ELIMINAR ESPACIOS*/ + SET vParkingCode = replace(vParkingCode,' ','') ; + + /*SINO EXISTE EL PARKING LO CREAMOS*/ + SELECT id INTO idParking + FROM vn.parking + WHERE code = vParkingCode COLLATE utf8_unicode_ci; + + IF idParking IS NULL THEN + IF LOCATE('-',vParkingCode) = 4 THEN + SELECT SUBSTRING_INDEX(vParkingCode,'-',1) INTO vColumn; + SELECT SUBSTRING_INDEX(vParkingCode,'-',-1) INTO vRow; + INSERT INTO vn.parking(`column`,`row`,code,sectorFk) + VALUES(vColumn,vRow,vParkingCode,2); + END IF; + END IF; + /*FIN INSERTAR PARKING*/ + + + SELECT id INTO vParkingFk + FROM vn.parking + WHERE `code` = vParkingCode COLLATE utf8_unicode_ci; + + IF length(vShelvingFk) > 6 THEN + + REPLACE vn.ticketParking(ticketFk,parkingFk) + VALUES (vShelvingFk, vParkingFk); + + REPLACE vn.shelving(code, parkingFk, isPrinted, parked) + VALUES(vShelvingFk, vParkingFk, TRUE, NOW()); + + CALL vn.ticketStatePrevious(vShelvingFk); + + ELSE + + + UPDATE vn.shelving + SET parkingFk = vParkingFk, parked = NOW() + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + SELECT (COUNT(*) > 0) AS IsUpdated + FROM vn.shelving + WHERE parkingFk = vParkingFk + AND `code` = vShelvingFk COLLATE utf8_unicode_ci; + + 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 `shelvingPark__` */; +/*!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 `shelvingPark__`(IN `vShelvingFk` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) +BEGIN + + DECLARE vParkingFk INT DEFAULT 0; + DECLARE idParking INT; + DECLARE vColumn VARCHAR(3); + DECLARE vRow VARCHAR(2); + DECLARE vReturn VARCHAR(50); + + /*ELIMINAR ESPACIOS*/ + SET vParkingCode = replace(vParkingCode,' ','') ; + + /*SINO EXISTE EL PARKING LO CREAMOS*/ + SELECT id INTO idParking + FROM vn.parking + WHERE code = vParkingCode COLLATE utf8_unicode_ci; + + IF idParking IS NULL THEN + IF LOCATE('-',vParkingCode) = 4 THEN + SELECT SUBSTRING_INDEX(vParkingCode,'-',1) INTO vColumn; + SELECT SUBSTRING_INDEX(vParkingCode,'-',-1) INTO vRow; + INSERT INTO vn.parking(`column`,`row`,code,sectorFk) + VALUES(vColumn,vRow,vParkingCode,2); + END IF; + END IF; + /*FIN INSERTAR PARKING*/ + + + SELECT id INTO vParkingFk + FROM vn.parking + WHERE `code` = vParkingCode COLLATE utf8_unicode_ci; + + IF length(vShelvingFk) > 6 THEN + /* + INSERT INTO vn.ticketParking(ticketFk,parkingFk) + VALUES(CAST(vShelvingFk as DECIMAL(10,0)), vParkingFk); + */ REPLACE vn.shelving(code, parkingFk, isPrinted, parked) VALUES(vShelvingFk, vParkingFk, TRUE, NOW()); @@ -42204,108 +45864,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketCalculate`( vAddressFk INT, vAgencyModeFk INT) proc: BEGIN -/** - * Calcula los articulos disponibles y sus precios - * - * @table tmp.item(itemFk) Listado de artículos a calcular - * @param vLanded Fecha de recepcion de mercancia - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.ticketCalculateItem(itemFk, available, producer, - * item, size, stems, category, inkFk, image, origin, price) - * @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk) - * @return tmp.ticketComponent - * @return tmp.ticketComponentPrice - * @return tmp.zoneGetShipped - - **/ - - DECLARE vAvailableCalc INT; - DECLARE vShipment DATE; - DECLARE vClient INT; - DECLARE vWarehouseFk SMALLINT; - DECLARE vDone BOOL; - DECLARE cTravelTree CURSOR FOR - SELECT warehouseFk, shipped FROM tmp.zoneGetShipped; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Establece los almacenes y las fechas que van a entrar al disponible - - SELECT clientFk INTO vClient - FROM address WHERE id = vAddressFk; - - CALL vn.zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buyFk` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT '0', - KEY `itemFk` (`itemFk`), - KEY `item_warehouse` (`itemFk`,`warehouseFk`) USING HASH - ) ENGINE=MEMORY DEFAULT CHARSET=utf8; - - OPEN cTravelTree; - - l: LOOP - SET vDone = FALSE; - FETCH cTravelTree INTO vWarehouseFk, vShipment; - - IF vDone THEN - LEAVE l; - END IF; - - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipment); - CALL buyUltimate (vWarehouseFk, vShipment); - - INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk) - SELECT vWarehouseFk, - i.item_id, - IFNULL(i.available, 0), - bu.buyFk - FROM `cache`.available i - JOIN tmp.item br ON br.itemFk = i.item_id - LEFT JOIN item it ON it.id = i.item_id - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = i.item_id - WHERE i.calc_id = vAvailableCalc - AND it.id != 100 - AND i.available > 0; - - DROP TEMPORARY TABLE tmp.buyUltimate; - END LOOP; - - CLOSE cTravelTree; - - CALL vn.ticketComponentCalculate(vAddressFk, vAgencyModeFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem - ENGINE = MEMORY - SELECT - b.itemFk, - SUM(b.available) available, - p.name producer, - i.name item, - i.size size, - i.stems, - i.category, - i.inkFk, - i.image, - o.code origin, bl.price - FROM tmp.ticketLot b - JOIN item i ON b.itemFk = i.id - LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible - JOIN origin o ON o.id = i.originFk - JOIN ( - SELECT MIN(price) price, itemFk - FROM tmp.ticketComponentPrice - GROUP BY itemFk - ) bl ON bl.itemFk = b.itemFk - GROUP BY b.itemFk; - +-- OBSOLETO utilizar catalog_calculate + CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -43344,7 +46904,7 @@ proc: BEGIN ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, tl.buyFk, i.typeFk, - IF(i.hasKgPrice,(b.packing * b.weight) / 1000, NULL) weightPacking + IF(i.hasKgPrice,b.weight / b.packing, NULL) weightGrouping FROM tmp.ticketLot tl JOIN buy b ON b.id = tl.buyFk JOIN item i ON i.id = tl.itemFk @@ -43489,7 +47049,7 @@ proc: BEGIN 1 rate, IF(tcc.groupingMode = 1, tcc.`grouping`, 1) grouping, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) / weightPacking AS DECIMAL(10,2)) priceKg + CAST(SUM(tcs.sumCost) / weightGrouping AS DECIMAL(10,2)) priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -43504,7 +47064,7 @@ proc: BEGIN 2 rate, tcc.packing grouping, SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg + SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -43519,7 +47079,7 @@ proc: BEGIN 3 rate, tcc.available grouping, SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightPacking priceKg + SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -44735,6 +48295,41 @@ 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 `ticketDown_PrintableSelection` */; +/*!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 `ticketDown_PrintableSelection`(vSectorFk INT) +BEGIN + + UPDATE vn.ticketDown td + JOIN + (SELECT DISTINCT t.id + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE p.sectorFk = vSectorFk + ) sub ON sub.id = td.ticketFk + JOIN vn.ticketDown_SelectionType tdst ON tdst.description = 'FREE' + JOIN vn.ticketDown_SelectionType tdst2 ON tdst2.description = 'SELECTED' + SET td.selected = tdst2.id + WHERE td.selected = tdst.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 `ticketFilter` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45742,8 +49337,8 @@ BEGIN */ IF viewAll IS true THEN SELECT * - FROM vn.ticketeToPreparePrepared ttp - WHERE ttp.Id_Ticket = vIdTicket; + FROM vn.salesToPrePrepare stpp + WHERE stpp.Id_Ticket = vIdTicket; ELSE SELECT * FROM vn.ticketToPrepare ttp @@ -46244,6 +49839,118 @@ BEGIN SET areaFk = vTaxArea; END IF; /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente + * No se debería cambiar el sistema por problemas con los decimales + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax; + CREATE TEMPORARY TABLE tmp.ticketTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT tmpTicket.ticketFk, + bp.pgcFk, + SUM(s.quantity * s.price * (100 - s.discount)/100 ) AS taxableBase, + pgc.rate, + tc.code, + bp.priority + FROM tmp.ticket tmpTicket + JOIN sale s ON s.ticketFk = tmpTicket.ticketFk + JOIN item i ON i.id = s.itemFk + JOIN ticket t ON t.id = tmpTicket.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN itemTaxCountry itc + ON itc.itemFk = i.id AND itc.countryFk = su.countryFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = itc.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tmpTicket.ticketFk, pgc.code,pgc.rate + HAVING taxableBase != 0) t + ORDER BY priority; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax; + CREATE TEMPORARY TABLE tmp.ticketServiceTax + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT tt.ticketFk, + SUM(ts.quantity * ts.price) AS taxableBase, + pgc.rate, + tc.code + FROM tmp.ticketTax tt + JOIN ticketService ts ON ts.ticketFk = tt.ticketFk + JOIN ticket t ON t.id = tt.ticketFk + JOIN supplier su ON su.id = t.companyFk + JOIN tmp.addressTaxArea ata + ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk + JOIN bookingPlanner bp + ON bp.countryFk = su.countryFk + AND bp.taxAreaFk = ata.areaFk + AND bp.taxClassFk = ts.taxClassFk + JOIN pgc ON pgc.code = bp.pgcFk AND pgc.rate = tt.rate + JOIN taxClass tc ON tc.id = bp.taxClassFk + GROUP BY tt.ticketFk, tt.code,tt.rate + HAVING taxableBase != 0; + + UPDATE tmp.ticketTax tt + JOIN tmp.ticketServiceTax ts ON tt.ticketFk = ts.ticketFk AND tt.code = ts.code AND tt.rate = ts.rate + SET tt.taxableBase = tt.taxableBase + ts.taxableBase; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount; + CREATE TEMPORARY TABLE tmp.ticketAmount + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, taxableBase, SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,code + FROM tmp.ticketTax + GROUP BY ticketFk, code; + + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + DROP TEMPORARY TABLE IF EXISTS tmp.addressTaxArea; +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_getTax__` */; +/*!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_getTax__`(vTaxArea VARCHAR(25)) + READS SQL DATA +BEGIN +/** + * Calcula la base imponible, el IVA y el recargo de equivalencia para + * un conjunto de tickets. + * + * @table tmp.ticket(ticketFk) Identificadores de los tickets a calcular + * @return tmp.ticketAmount + * @return tmp.ticketTax Impuesto desglosado para cada ticket. + */ + DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; + CREATE TEMPORARY TABLE tmp.addressCompany + (INDEX (addressFk, companyFk)) + ENGINE = MEMORY + SELECT DISTINCT t.addressFk, t.companyFk + FROM tmp.ticket tmpTicket + JOIN ticket t ON t.id = tmpTicket.ticketFk; + + CALL addressTaxArea (); + + IF vTaxArea > '' THEN + UPDATE tmp.addressTaxArea + SET areaFk = vTaxArea; + END IF; + /** Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente * No se debería cambiar el sistema por problemas con los decimales */ @@ -46646,12 +50353,13 @@ BEGIN * @table tmp.user(userFk) * @return tmp.timeBusinessCalculate */ - + DECLARE vHoursFullTime INT DEFAULT 40; + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; - DROP TEMPORARY TABLE IF EXISTS tmp.workerHasNotCalendar; + DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime; CREATE TEMPORARY TABLE tmp.timeBusinessCalculate - SELECT dated, + SELECT dated, businessFk, userFk, departmentFk, @@ -46664,15 +50372,17 @@ BEGIN SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, timeWorkSeconds / 3600 timeBusinessDecimal, type, + permissionrate, hoursWeek FROM(SELECT t.dated, b.business_id businessFk, w.userFk, bl.department_id departmentFk, - GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-') hourStart , - GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-') hourEnd, - IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0) timeWorkSeconds, + IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , + IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, + IF(cl.hours_week = vHoursFullTime, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, cs.type, + cs.permissionRate, cl.hours_week hoursWeek FROM vn.time t LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) @@ -46692,45 +50402,32 @@ BEGIN GROUP BY w.userFk,dated )sub; - CREATE TEMPORARY TABLE tmp.workerHasNotCalendar - SELECT userFK,hoursWeek - FROM tmp.timeBusinessCalculate - GROUP BY userFK - HAVING SUM(timeWorkSeconds)=0; + + UPDATE tmp.timeBusinessCalculate t + SET t.timeWorkSeconds = vHoursFullTime / 5 * 3600, + t.timeWorkSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), + t.timeWorkDecimal = vHoursFullTime / 5, + t.timeBusinessSeconds = vHoursFullTime / 5 * 3600, + t.timeBusinessSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), + t.timeBusinessDecimal = vHoursFullTime / 5 + WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND hoursWeek = vHoursFullTime ; - UPDATE tmp.timeBusinessCalculate t, tmp.workerHasNotCalendar w - SET t.timeWorkSeconds = w.hoursweek / 5 * 3600, - t.timeWorkSexagesimal = SEC_TO_TIME( w.hoursweek / 5 * 3600), - t.timeWorkDecimal = w.hoursweek / 5, - t.timeBusinessSeconds = w.hoursweek / 5 * 3600, - t.timeBusinessSexagesimal = SEC_TO_TIME( w.hoursweek / 5 * 3600), - t.timeBusinessDecimal = w.hoursweek / 5 - WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND t.userFk= w.userFk; - - - - UPDATE tmp.timeBusinessCalculate t - SET t.timeWorkSeconds = 0, - t.timeWorkSexagesimal = 0, - t.timeWorkDecimal = 0 - WHERE type IN ('Vacaciones','Baja enfermedad común','Baja mutua','Permiso retribuido','Visita médico','Visita comercial','Excedencia', 'Parte'); - - UPDATE tmp.timeBusinessCalculate t - SET t.timeWorkSeconds = t.timeWorkSeconds/2, - t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds/2), - t.timeWorkDecimal = t.timeWorkDecimal/2 - WHERE type IN ('Vacaciones 1/2 día','Permiso retribuido 1/2 día'); - + UPDATE tmp.timeBusinessCalculate t + SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate) , + t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate)), + t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionrate) + WHERE permissionrate <> 0; + UPDATE tmp.timeBusinessCalculate t JOIN postgresql.calendar_labour cl ON cl.day = t.dated JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = cl.workcenter_id SET t.timeWorkSeconds = 0, t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, - t.type = 'Festivo'; + t.permissionrate = 1, + t.type = 'Festivo' + WHERE t.type IS NULL; - DROP TEMPORARY TABLE tmp.workerHasNotCalendar; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -46847,6 +50544,117 @@ BEGIN DROP TEMPORARY TABLE tmp.`user`; +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 `timeBusiness_calculate__` */; +/*!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 `timeBusiness_calculate__`(vDatedFrom DATETIME, vDatedTo DATETIME) +BEGIN + +/** + * Horas que debe trabajar un empleado según contrato y día. + * @param vDatedFrom workerTimeControl + * @param vDatedTo workerTimeControl + * @table tmp.user(userFk) + * @return tmp.timeBusinessCalculate + */ + + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; + DROP TEMPORARY TABLE IF EXISTS tmp.workerHasNotCalendar; + + CREATE TEMPORARY TABLE tmp.timeBusinessCalculate + SELECT dated, + businessFk, + userFk, + departmentFk, + hourStart, + hourEnd, + timeWorkSeconds, + SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal, + timeWorkSeconds / 3600 timeWorkDecimal, + timeWorkSeconds timeBusinessSeconds, + SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, + timeWorkSeconds / 3600 timeBusinessDecimal, + type, + hoursWeek + FROM(SELECT t.dated, + b.business_id businessFk, + w.userFk, + bl.department_id departmentFk, + GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-') hourStart , + GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-') hourEnd, + IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0) timeWorkSeconds, + cs.type, + cl.hours_week hoursWeek + FROM vn.time t + LEFT JOIN postgresql.business b ON t.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) + LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id + LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id + LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id + JOIN tmp.`user` u ON u.userFK = w.userFK + JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id + LEFT JOIN postgresql.business_labour_payroll AS bp ON bl.business_id = bp.business_id + LEFT JOIN postgresql.professional_category AS pc ON bl.professional_category_id = pc.professional_category_id + LEFT JOIN postgresql.workcenter AS wc ON bl.workcenter_id = wc.workcenter_id + LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id + LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(t.dated)+1 + LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id and ce.date = t.dated + LEFT JOIN postgresql.calendar_state cs ON cs.calendar_state_id = ce.calendar_state_id + WHERE t.dated BETWEEN vDatedFrom AND vDatedTo + GROUP BY w.userFk,dated + )sub; + + CREATE TEMPORARY TABLE tmp.workerHasNotCalendar + SELECT userFK,hoursWeek + FROM tmp.timeBusinessCalculate + GROUP BY userFK + HAVING SUM(timeWorkSeconds)=0; + + UPDATE tmp.timeBusinessCalculate t, tmp.workerHasNotCalendar w + SET t.timeWorkSeconds = w.hoursweek / 5 * 3600, + t.timeWorkSexagesimal = SEC_TO_TIME( w.hoursweek / 5 * 3600), + t.timeWorkDecimal = w.hoursweek / 5, + t.timeBusinessSeconds = w.hoursweek / 5 * 3600, + t.timeBusinessSexagesimal = SEC_TO_TIME( w.hoursweek / 5 * 3600), + t.timeBusinessDecimal = w.hoursweek / 5 + WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND t.userFk= w.userFk; + + + + UPDATE tmp.timeBusinessCalculate t + SET t.timeWorkSeconds = 0, + t.timeWorkSexagesimal = 0, + t.timeWorkDecimal = 0 + WHERE type IN ('Vacaciones','Baja enfermedad común','Baja mutua','Permiso retribuido','Visita médico','Visita comercial','Excedencia', 'Parte'); + + UPDATE tmp.timeBusinessCalculate t + SET t.timeWorkSeconds = t.timeWorkSeconds/2, + t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds/2), + t.timeWorkDecimal = t.timeWorkDecimal/2 + WHERE type IN ('Vacaciones 1/2 día','Permiso retribuido 1/2 día'); + + UPDATE tmp.timeBusinessCalculate t + JOIN postgresql.calendar_labour cl ON cl.day = t.dated + JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = cl.workcenter_id + SET t.timeWorkSeconds = 0, + t.timeWorkSexagesimal = 0, + t.timeWorkDecimal = 0, + t.type = 'Festivo'; + + DROP TEMPORARY TABLE tmp.workerHasNotCalendar; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47010,6 +50818,159 @@ BEGIN DROP TEMPORARY TABLE tmp.`user`; +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 `timeWorkerControl_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 = 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 `timeWorkerControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +proc: BEGIN +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekScope INT; + DECLARE vDayStayMax INT; + DECLARE vProblem VARCHAR(20) DEFAULT NULL; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vDepartmentFk INT; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'out'; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVO DIA + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + SELECT wtcu.departmentFk INTO vDepartmentFk + FROM vn.workerTimeControlUserInfo wtcu + WHERE wtcu.userFk = vUserFk; + IF (SELECT COUNT(td.tabletFk) + FROM vn.tabletDepartment td + WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk + ) = 0 THEN + SELECT "No perteneces a este departamento." AS problem; + LEAVE proc; + END IF; + END IF; + + -- VERIFICAR DESCANSO DIARIO + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + SELECT "Descansos 12 h" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2)<>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed >= vLastIn + ) THEN + SELECT "Dias con fichadas impares" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() + AND cs.isAllowedToWork = FALSE + AND w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + SELECT vCalendarStateType AS problem; + LEAVE proc; + END IF; + + + -- VERIFICAR CNTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + 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 <= vDated + AND IFNULL(b.date_end,vDated) >= vDated + ) = 0 THEN + SELECT "Dia no laborable" AS problem; + LEAVE proc; + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @gap:= unix_timestamp((NOW() - INTERVAL vWeekScope SECOND)); -- COLOCA EL TIEMPO DE OUT, EN EL CASO DE QUE LA PRIMERA FICHADA DEL PERIODO SEA IN, PARA TENER UN PUNTO DE PARTIDA + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(direction='out', @gap:= -unix_timestamp(timed), @gap:= @gap + unix_timestamp(timed)) as alias1 , + IF(@gap - vWeekBreak >= 0 , @vHasBreakWeek := TRUE, @vHasBreakWeek := @vHasBreakWeek) as alias2 + FROM vn.workerTimeControl + WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) + AND userFk= vUserFk + AND direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SELECT "Descansos 36 h" AS problem; + LEAVE proc; + END IF; + + DROP TEMPORARY TABLE tmp.trash; + + ELSE -- DIA ACTUAL + + -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO + SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= vLastIn + ORDER BY timed; + + IF vTimedWorked > vDayWorkMax THEN + SELECT "Jornadas" AS problem; + LEAVE proc; + END IF; + + END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47931,10 +51892,12 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlAdd`(IN vUserFk INT, IN vWarehouseFk INT, IN vDated DATETIME) BEGIN - INSERT INTO workerTimeControl(userFk, timed, manual, warehouseFk) + /*INSERT INTO workerTimeControl(userFk, timed, manual, warehouseFk) VALUES(vUserFk, vDated, FALSE, vWarehouseFk); - CALL vn.workerTimeControlSOWP(vUserFk , vDated); + CALL vn.workerTimeControlSOWP(vUserFk , vDated);*/ + + CALL vn.workerTimeControl_add(vUserFk,vWarehouseFk,NOW(),FALSE); END ;; @@ -48081,6 +52044,51 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) +BEGIN + + DECLARE vDirection VARCHAR(6); + DECLARE vLastIn DATETIME; + + + SELECT vn.timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; + + IF vDirection = 'out' THEN + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in' + AND timed < vTimed; + + UPDATE vn.workerTimeControl wtc + SET wtc.direction = 'middle' + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vLastIn AND vTimed; + + END IF; + + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) + VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); + + CALL vn.workerTimeControlSOWP(vUserFk, vTimed); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerWeekControl` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48091,7 +52099,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `workerWeekControl`(vUserFk INT, vDated DATE, vTabletFk VARCHAR(100)) BEGIN /* Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador @@ -48109,6 +52117,9 @@ DECLARE vHasSignedToday BOOLEAN; DECLARE v12hoursInMinutes INT DEFAULT 719; DECLARE v36hoursInMinutes INT DEFAULT 2159; DECLARE vCantWork VARCHAR(50) DEFAULT ''; +DECLARE vDepartmentFk INT; +DECLARE isEnabled BOOLEAN DEFAULT TRUE; + SELECT COUNT(*) INTO vHasSignedToday FROM vn.workerTimeControl WHERE timed >= vDated AND userFk = vUserFk; @@ -48181,6 +52192,21 @@ SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork WHERE w.userFk = vUserFk AND b.date_start <= vDated AND IFNULL(b.date_end,vDated) >= vDated; + +-- Departamento si vTabletFk es 0 no hacemos comprobacion (Madrid y Vilassar) +IF vTabletFk <> '0' THEN +-- 1 Obtener el departamento del usuario + SELECT wtcu.departmentFk INTO vDepartmentFk + FROM vn.workerTimeControlUserInfo wtcu + WHERE wtcu.userFk = vUserFk; +-- 2 Comprobar si la tablet pertenece al departamento + SELECT COUNT(td.tabletFk) INTO isEnabled + FROM vn.tabletDepartment td + WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk; + +END IF; + + IF vJornadas IS NOT NULL THEN @@ -48203,7 +52229,11 @@ IF vJornadas IS NOT NULL THEN SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis - + + UNION ALL + + SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis + ; ELSE @@ -48227,7 +52257,10 @@ ELSE SELECT IF (LENGTH(vCantWork),CONCAT('Dia no laborable: ', vCantWork),'Dia laborable') as Item, '' as Cantidad, IF(LENGTH(vCantWork),'Error', 'Correcto') as Análisis - + + UNION ALL + + SELECT 'El fichador no pertenece a tu departamento.' as Item, '' as Cantidad, IF(isEnabled, 'Correcto','Error') as Análisis ; END IF; @@ -48675,17 +52708,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 `zoneAddPostcode` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneAddPostcode__` */; /*!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 `zoneAddPostcode`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneAddPostcode__`() BEGIN /** * Añade un código postal a una población y regenera el arbol de zonas. @@ -48764,19 +52797,32 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_calcTree`() BEGIN +/** + * Calculates the #path, #lft, #rgt, #sons and #depth columns of + * the #zoneGeo table. To build the tree, it uses the #parentFk + * column. + */ DECLARE vIndex INT DEFAULT 0; DECLARE vSons INT; - UPDATE vn.zoneGeo SET - path = NULL, - lft = NULL, - rgt = NULL, - depth = 0, - sons = 0; + DROP TEMPORARY TABLE IF EXISTS tNestedTree; + CREATE TEMPORARY TABLE tNestedTree + SELECT id, path, lft, rgt, depth, sons + FROM zoneGeo LIMIT 0; SET max_sp_recursion_depth = 5; - CALL vn.zoneGeo_calcTreeRec(NULL, '', 0, vIndex, vSons); + CALL zoneGeo_calcTreeRec(NULL, '/', 0, vIndex, vSons); SET max_sp_recursion_depth = 0; + + UPDATE zoneGeo z + JOIN tNestedTree t ON t.id = z.id + SET z.path = t.path, + z.lft = t.lft, + z.rgt = t.rgt, + z.depth = t.depth, + z.sons = t.sons; + + DROP TEMPORARY TABLE tNestedTree; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48794,31 +52840,43 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_calcTreeRec`( - vParentFk INT, + vSelf INT, vPath VARCHAR(255), vDepth INT, INOUT vIndex INT, OUT vSons INT ) BEGIN +/** + * Calculates and sets the #path, #lft, #rgt, #sons and #depth + * columns for all children of the passed node. Once calculated + * the last node rgt index and the number of sons are returned. + * To update it's children, this procedure calls itself recursively + * for each one. + * + * @vSelf The node identifier + * @vPath The initial path + * @vDepth The initial depth + * @vIndex The initial lft index + * @vSons The number of direct sons + */ DECLARE vChildFk INT; DECLARE vLft INT; DECLARE vMySons INT; DECLARE vDone BOOL; - DECLARE vChilds CURSOR FOR + DECLARE vChildren CURSOR FOR SELECT id FROM zoneGeo - WHERE (vParentFk IS NULL AND parentFk IS NULL) - OR (vParentFk IS NOT NULL AND parentFk = vParentFk); + WHERE (vSelf IS NULL AND parentFk IS NULL) + OR (vSelf IS NOT NULL AND parentFk = vSelf); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; SET vSons = 0; - SET vPath = CONCAT(vPath, '/'); - OPEN vChilds; + OPEN vChildren; myLoop: LOOP SET vDone = FALSE; - FETCH vChilds INTO vChildFk; + FETCH vChildren INTO vChildFk; IF vDone THEN LEAVE myLoop; @@ -48830,7 +52888,7 @@ BEGIN CALL zoneGeo_calcTreeRec( vChildFk, - CONCAT(vPath, vChildFk), + CONCAT(vPath, vChildFk, '/'), vDepth + 1, vIndex, vMySons @@ -48838,22 +52896,22 @@ BEGIN SET vIndex = vIndex + 1; - UPDATE zoneGeo - SET path = vPath, + INSERT INTO tNestedTree + SET id = vChildFk, + path = vPath, lft = vLft, rgt = vIndex, - depth = vDepth, - sons = vMySons - WHERE id = vChildFk; + depth = vDepth, + sons = vMySons; END LOOP; - CLOSE vChilds; + CLOSE vChildren; 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 DROP PROCEDURE IF EXISTS `zoneGeo_checkName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -48863,10 +52921,12 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_check`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_checkName`(vName VARCHAR(255)) BEGIN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'Column `geoFk` cannot be modified'; + IF vName = '' THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Column `name` cannot be empty'; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48885,6 +52945,12 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_delete`(vSelf INT) BEGIN +/** + * Deletes a node from the #zoneGeo table. Also sets a mark + * to force the tree recalculation. + * + * @vSelf The node identifier + */ DELETE FROM zoneGeo WHERE id = vSelf; UPDATE zoneGeoRecalc SET isChanged = TRUE; END ;; @@ -48925,8 +52991,7 @@ proc: BEGIN IF vIsChanged THEN UPDATE zoneGeoRecalc SET isChanged = FALSE; - -- FIXME: Disabled until geo is fixed - -- CALL vn.zoneGeo_calcTree; + CALL vn.zoneGeo_calcTree; END IF; DO RELEASE_LOCK('vn.zoneGeo_doCalc'); @@ -48948,6 +53013,13 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGeo_setParent`(vSelf INT, vParentFk INT) BEGIN +/** + * Updates the parent of a node. Also sets a mark + * to force the tree recalculation. + * + * @vSelf The node identifier + * @vParentFk The new parent identifier + */ UPDATE zoneGeo SET parentFk = vParentFk WHERE id = vSelf; @@ -48958,6 +53030,26 @@ 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_throwNotEditable` */; +/*!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_throwNotEditable`() +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 `zoneGetAgency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49189,37 +53281,44 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded`(vShipped DATE, vAddress INT, vAgencyMode INT, vWarehouse INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk 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 +* @param vAddressFk Id de consignatario, %NULL para recogida +* @param vAgencyModeFk Id agencia * @table tmp.zoneGetLanded Datos de recepción */ DECLARE vGeoFk INT; - SELECT p.geoFk INTO vGeoFk + 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 + WHERE a.id = vAddressFk 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 + SELECT + id zoneFk, + vShipped shipped, + delivered landed, + vWarehouseFk warehouseFk, + agencyModeFk, + isIncluded + FROM ( + SELECT zi.isIncluded, zc.delivered, z.id, z.agencyModeFk 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 @@ -49228,8 +53327,8 @@ BEGIN 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 + AND z.agencyModeFk = vAgencyModeFk + AND z.warehouseFk = vWarehouseFk ORDER BY zgFather.depth DESC) t GROUP BY zoneFk HAVING isIncluded > 0 @@ -49294,9 +53393,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -49310,9 +53409,10 @@ BEGIN * @param vAgencyModeFk Id de la agencia * @return tmp.zoneGetShipped */ + DECLARE vGeoFk INT; - SELECT p.geoFk INTO vGeoFk + 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 @@ -49322,11 +53422,12 @@ BEGIN SELECT * FROM ( SELECT * FROM ( - SELECT z.id, + SELECT z.id zoneFk, TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, vLanded landed, - zi.isIncluded, - z.agencyModeFk + vWarehouseFk warehouseFk, + z.agencyModeFk, + 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 @@ -49338,7 +53439,7 @@ BEGIN 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 + GROUP BY zoneFk HAVING isIncluded > 0 ORDER BY shipped) t @@ -49840,6 +53941,105 @@ 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 `zone_getLeaves` */; +/*!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 `zone_getLeaves`( + vSelf INT, + vParentFk INT, + vSearch VARCHAR(255) +) +BEGIN + DECLARE vIsNumber BOOL; + DECLARE vIsSearch BOOL DEFAULT vSearch IS NOT NULL AND vSearch != ''; + + DROP TEMPORARY TABLE IF EXISTS tNodes; + CREATE TEMPORARY TABLE tNodes + (UNIQUE (id)) + ENGINE = MEMORY + SELECT id FROM zoneGeo LIMIT 0; + + IF vIsSearch THEN + SET vIsNumber = vSearch REGEXP '^[0-9]+$'; + + INSERT INTO tNodes + SELECT id FROM zoneGeo + WHERE (vIsNumber AND `name` = vSearch) + OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%')) + LIMIT 1000; + ELSEIF vParentFk IS NULL THEN + INSERT INTO tNodes + SELECT geoFk FROM zoneIncluded + WHERE zoneFk = vSelf; + END IF; + + IF vParentFk IS NULL THEN + DROP TEMPORARY TABLE IF EXISTS tChilds; + CREATE TEMPORARY TABLE tChilds + ENGINE = MEMORY + SELECT id FROM tNodes; + + DROP TEMPORARY TABLE IF EXISTS tParents; + CREATE TEMPORARY TABLE tParents + ENGINE = MEMORY + SELECT id FROM zoneGeo LIMIT 0; + + myLoop: LOOP + DELETE FROM tParents; + INSERT INTO tParents + SELECT parentFk id + FROM zoneGeo g + JOIN tChilds c ON c.id = g.id + WHERE g.parentFk IS NOT NULL; + + INSERT IGNORE INTO tNodes + SELECT id FROM tParents; + + IF ROW_COUNT() = 0 THEN + LEAVE myLoop; + END IF; + + DELETE FROM tChilds; + INSERT INTO tChilds + SELECT id FROM tParents; + END LOOP; + + DROP TEMPORARY TABLE + tChilds, + tParents; + END IF; + + IF !vIsSearch THEN + INSERT IGNORE INTO tNodes + SELECT id FROM zoneGeo + WHERE parentFk <=> vParentFk; + END IF; + + SELECT g.id, + g.`name`, + g.parentFk, + g.sons, + isIncluded selected + FROM zoneGeo g + JOIN tNodes n ON n.id = g.id + LEFT JOIN zoneIncluded i + ON i.geoFk = g.id AND i.zoneFk = vSelf + ORDER BY depth, selected DESC, `name`; + + DROP TEMPORARY TABLE tNodes; +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 */ ; @@ -49916,35 +54116,32 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn2008` /*!40100 DEFAULT CHARACTER SET USE `vn2008`; -- --- Table structure for table `Agencias` +-- Temporary table structure for view `Agencias` -- DROP TABLE IF EXISTS `Agencias`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Agencias` ( - `Id_Agencia` int(11) NOT NULL AUTO_INCREMENT, - `Agencia` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Vista` int(11) DEFAULT '0', - `m3` double DEFAULT '0', - `cod71` tinyint(3) unsigned DEFAULT '0', - `web` smallint(1) unsigned zerofill NOT NULL DEFAULT '0', - `agency_id` smallint(6) NOT NULL, - `agency_service_id` tinyint(4) NOT NULL DEFAULT '1', - `inflacion` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', - `is_volumetric` tinyint(1) NOT NULL DEFAULT '0', - `send_mail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, - `show_AgencyName` tinyint(1) DEFAULT '1', - `tpv` tinyint(1) NOT NULL DEFAULT '1', - `externalAgency` tinyint(1) NOT NULL DEFAULT '0', - `flag` blob, - `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`Id_Agencia`), - KEY `Agencias` (`Agencia`), - KEY `Vista` (`Vista`) -) ENGINE=InnoDB AUTO_INCREMENT=1232 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Agencias`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Agencias` AS SELECT + 1 AS `Id_Agencia`, + 1 AS `Agencia`, + 1 AS `description`, + 1 AS `Vista`, + 1 AS `m3`, + 1 AS `cod71`, + 1 AS `web`, + 1 AS `agency_id`, + 1 AS `agency_service_id`, + 1 AS `inflacion`, + 1 AS `is_volumetric`, + 1 AS `send_mail`, + 1 AS `tpv`, + 1 AS `code`, + 1 AS `show_AgencyName`, + 1 AS `externalAgency`, + 1 AS `flag`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Agencias_dits` @@ -49982,9 +54179,9 @@ CREATE TABLE `Agencias_province` ( PRIMARY KEY (`province_id`,`agency_id`,`warehouse_id`), KEY `warehouse_id` (`warehouse_id`), KEY `agency_id` (`agency_id`), - CONSTRAINT `Agencias_province_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Agencias_province_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Agencias_province_ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_province_ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `agency` (`agency_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Agencias_province_ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -50005,282 +54202,85 @@ CREATE TABLE `Agencias_zonas` ( `inflacion` decimal(5,2) NOT NULL DEFAULT '1.00', PRIMARY KEY (`Id_Agencia`,`zona`,`Id_Article`,`warehouse_id`), KEY `Id_Article` (`Id_Article`), - CONSTRAINT `Agencias_zonas_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_zonas_ibfk_2` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Agencias_zonas_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Agencias_zonas_ibfk_2` FOREIGN KEY (`Id_Agencia`) REFERENCES `vn`.`agencyMode` (`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 `Articles` +-- Temporary table structure for view `Articles` -- DROP TABLE IF EXISTS `Articles`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Articles` ( - `Id_Article` int(11) NOT NULL AUTO_INCREMENT, - `Equivalente` int(11) unsigned DEFAULT NULL, - `Article` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Medida` int(10) unsigned DEFAULT NULL, - `Tallos` int(11) DEFAULT '1', - `PVP` double DEFAULT '0', - `Imprimir` tinyint(1) NOT NULL DEFAULT '0', - `Albaranero` tinyint(1) NOT NULL DEFAULT '0', - `iva_group_id` tinyint(4) unsigned NOT NULL DEFAULT '1', - `Familia` varchar(3) COLLATE utf8_unicode_ci DEFAULT 'VT', - `caja` tinyint(1) NOT NULL DEFAULT '0', - `Categoria` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `id_origen` tinyint(2) unsigned NOT NULL, - `do_photo` tinyint(4) NOT NULL DEFAULT '0', - `Foto` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Color` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `Nicho` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `Codintrastat` int(8) unsigned zerofill DEFAULT NULL, - `Min` tinyint(1) NOT NULL DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `offer` tinyint(4) NOT NULL DEFAULT '0', - `bargain` tinyint(4) NOT NULL DEFAULT '0', - `comments` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'renombrar: reference', - `tipo_id` smallint(5) unsigned NOT NULL, - `generic` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', - `producer_id` mediumint(3) unsigned DEFAULT NULL, - `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `density` decimal(10,3) NOT NULL DEFAULT '167.000' COMMENT 'Almacena la densidad en kg/m3 para el calculo de los portes, si no se especifica se pone por defecto la del tipo en un trigger', - `relevancy` tinyint(1) NOT NULL DEFAULT '0', - `expenceFk` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '7001000000', - `isActive` tinyint(1) NOT NULL DEFAULT '1', - `longName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `subName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value5` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag6` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value6` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value7` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value8` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `value9` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `tag10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, - `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' COMMENT 'Se muestra el precio por kilo ', - `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`Id_Article`), - KEY `Article` (`Article`), - KEY `Color` (`Color`), - KEY `id_origen` (`id_origen`), - KEY `Codintrastat` (`Codintrastat`), - KEY `iva_group_id` (`iva_group_id`), - KEY `tipo_id` (`tipo_id`), - KEY `producer_id` (`producer_id`), - KEY `expenceFk_idx` (`expenceFk`), - KEY `ArticlesIsActive_idx` (`isActive`), - 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 `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=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 */ ; -/*!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`.`item_beforeInsert` - BEFORE INSERT ON `Articles` - FOR EACH ROW -BEGIN - DECLARE vDensity DOUBLE; - DECLARE vInsertId INT; - DECLARE vProducerFk VARCHAR(50); - DECLARE vInkName VARCHAR(50); - - IF NEW.density IS NULL THEN - SELECT density INTO vDensity - FROM Tipos WHERE tipo_id = NEW.tipo_id; - - SET NEW.density = vDensity; - END IF; - - -- Migration -/* - SET NEW.longName = NEW.Article; - - IF NEW.producer_id is not null THEN - SELECT name INTO vProducerFk FROM producer WHERE producer_id = NEW.producer_id; - SET NEW.subname = vProducerFk; - END IF; - - IF NEW.Medida IS NOT NULL AND NEW.value5 IS NULL THEN - SET NEW.tag5 ='Medida'; - SET NEW.value5 = NEW.medida; - END IF; - - IF NEW.Color IS NOT NULL AND NEW.value6 IS NULL THEN - SET NEW.tag6 ='Color'; - SELECT name INTO vInkName FROM vn.ink i where i.id = NEW.Color; - SET NEW.value6 = vInkName; - END IF; - - IF NEW.Categoria IS NOT NULL AND NEW.value7 IS NULL THEN - SET NEW.tag7 ='Categoria'; - SET NEW.value7 = NEW.Categoria; - END IF; - - IF NEW.Tallos IS NOT NULL AND NEW.value8 IS NULL THEN - SET NEW.tag8 ='Tallos'; - SET NEW.value8 = NEW.Tallos; - 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`.`Articles_afterInsert` - AFTER INSERT ON `Articles` - FOR EACH ROW -BEGIN - CALL hedera.image_ref('catalog', NEW.Foto); - - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.Id_Article, 1, NEW.iva_group_id; - - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.Id_Article, 5, NEW.iva_group_id; - - INSERT INTO vn.itemTaxCountry(itemFk, countryFk, taxClassFk) - SELECT NEW.Id_Article, 30, NEW.iva_group_id; -/* - IF NEW.tipo_id IS NOT NULL THEN - INSERT INTO vn.itemTag (itemFk, tagFk, priority) - SELECT NEW.Id_Article, tagFk, priority FROM vn.itemTypeTag - WHERE itemTypeFk = NEW.tipo_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 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`.`item_afterUpdate` - AFTER UPDATE ON `Articles` - FOR EACH ROW -BEGIN - IF !(NEW.Foto <=> OLD.Foto) THEN - CALL hedera.image_unref('catalog', OLD.Foto); - CALL hedera.image_ref('catalog', NEW.Foto); - 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`.`item_afterDelete` - AFTER DELETE ON `Articles` - FOR EACH ROW -BEGIN - CALL hedera.image_unref('catalog', OLD.Foto); -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 `Articles`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Articles` AS SELECT + 1 AS `Id_Article`, + 1 AS `Article`, + 1 AS `tipo_id`, + 1 AS `Medida`, + 1 AS `Color`, + 1 AS `Categoria`, + 1 AS `Tallos`, + 1 AS `id_origen`, + 1 AS `description`, + 1 AS `producer_id`, + 1 AS `Codintrastat`, + 1 AS `offer`, + 1 AS `caja`, + 1 AS `expenceFk`, + 1 AS `bargain`, + 1 AS `comments`, + 1 AS `relevancy`, + 1 AS `Foto`, + 1 AS `generic`, + 1 AS `density`, + 1 AS `iva_group_id`, + 1 AS `PVP`, + 1 AS `Min`, + 1 AS `isActive`, + 1 AS `longName`, + 1 AS `subName`, + 1 AS `tag5`, + 1 AS `value5`, + 1 AS `tag6`, + 1 AS `value6`, + 1 AS `tag7`, + 1 AS `value7`, + 1 AS `tag8`, + 1 AS `value8`, + 1 AS `tag9`, + 1 AS `value9`, + 1 AS `tag10`, + 1 AS `value10`, + 1 AS `minimum`, + 1 AS `upToDown`, + 1 AS `compression`, + 1 AS `hasKgPrice`, + 1 AS `Equivalente`, + 1 AS `Imprimir`, + 1 AS `Albaranero`, + 1 AS `Familia`, + 1 AS `do_photo`, + 1 AS `Nicho`, + 1 AS `odbc_date`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Articles_botanical` +-- Temporary table structure for view `Articles_botanical` -- DROP TABLE IF EXISTS `Articles_botanical`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Articles_botanical` ( - `Id_Article` int(11) NOT NULL, - `botanical` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `genus_id` mediumint(8) unsigned DEFAULT NULL, - `specie_id` mediumint(8) unsigned DEFAULT NULL, - PRIMARY KEY (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles'; -/*!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 `Articles_botanical_bi` BEFORE INSERT ON `Articles_botanical` FOR EACH ROW -BEGIN - IF NEW.botanical = '' THEN - SET NEW.botanical = NULL; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!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 `Articles_botanical_bu` BEFORE UPDATE ON `Articles_botanical` FOR EACH ROW -BEGIN - IF NEW.botanical = '' THEN - SET NEW.botanical = NULL; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `Articles_botanical`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Articles_botanical` AS SELECT + 1 AS `Id_Article`, + 1 AS `botanical`, + 1 AS `genus_id`, + 1 AS `specie_id`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Articles_dits` @@ -50301,31 +54301,26 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=21443 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21444 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Articles_nicho` +-- Temporary table structure for view `Articles_nicho` -- DROP TABLE IF EXISTS `Articles_nicho`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Articles_nicho` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Article` int(11) NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL DEFAULT '1', - `nicho` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `modificationDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `reserve` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `pickable` int(11) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - UNIQUE KEY `Id_Article_UNIQUE` (`Id_Article`,`warehouse_id`), - 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=888485 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Articles_nicho`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Articles_nicho` AS SELECT + 1 AS `id`, + 1 AS `Id_Article`, + 1 AS `warehouse_id`, + 1 AS `nicho`, + 1 AS `reserve`, + 1 AS `pickable`, + 1 AS `modificationDate`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Baldas` @@ -50343,30 +54338,23 @@ CREATE TABLE `Baldas` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Bancos` +-- Temporary table structure for view `Bancos` -- DROP TABLE IF EXISTS `Bancos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Bancos` ( - `Id_Banco` int(11) NOT NULL DEFAULT '0', - `Banco` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Cuenta` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `cash` smallint(6) NOT NULL DEFAULT '0', - `warehouse_id` smallint(5) unsigned NOT NULL DEFAULT '1', - `entity_id` int(10) unsigned NOT NULL, - `activo` tinyint(4) NOT NULL DEFAULT '1', - `currencyFk` tinyint(3) unsigned DEFAULT '1', - PRIMARY KEY (`Id_Banco`), - KEY `BancosBanco` (`Banco`), - KEY `fk_Bancos_entity1_idx` (`entity_id`), - KEY `foreignkey1_idx` (`cash`), - KEY `Bancoscurrency_idx` (`currencyFk`), - CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `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 */; +/*!50001 DROP VIEW IF EXISTS `Bancos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Bancos` AS SELECT + 1 AS `Id_Banco`, + 1 AS `Banco`, + 1 AS `Cuenta`, + 1 AS `cash`, + 1 AS `entity_id`, + 1 AS `activo`, + 1 AS `currencyFk`, + 1 AS `warehouse_id`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Bancos_poliza` @@ -50389,9 +54377,9 @@ CREATE TABLE `Bancos_poliza` ( PRIMARY KEY (`poliza_id`), KEY `Id_Banco_Poliza_idx` (`Id_Banco`), KEY `Id_Poliza_Empresa_idx` (`empresa_id`), - CONSTRAINT `Id_Banco_Poliza` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, - CONSTRAINT `Id_Poliza_Empresa` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lineas de credito asociadas a cuentas corrientes'; + CONSTRAINT `Id_Banco_Poliza` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `Id_Poliza_Empresa` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lineas de credito asociadas a cuentas corrientes'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50449,8 +54437,8 @@ CREATE TABLE `Cajas` ( KEY `empresa_id` (`empresa_id`), 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=721258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=730559 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 */ ; @@ -50488,233 +54476,79 @@ CREATE TABLE `Clases` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Clientes` +-- Temporary table structure for view `Clientes` -- DROP TABLE IF EXISTS `Clientes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes` ( - `id_cliente` int(11) NOT NULL AUTO_INCREMENT, - `cliente` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `descuento` tinyint(3) unsigned NOT NULL DEFAULT '0', - `default_address` int(11) DEFAULT NULL, - `domicilio` longtext COLLATE utf8_unicode_ci, - `if` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, - `telefono` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `fax` varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL, - `e-mail` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, - `cc` varchar(23) COLLATE utf8_unicode_ci DEFAULT NULL, - `vencimiento` smallint(6) NOT NULL DEFAULT '5', - `recibo` int(11) DEFAULT '1' COMMENT 'Deprecated', - `oficial` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Deprecated', - `contabilizado` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', - `movil` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `Cuenta` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `RE` tinyint(1) NOT NULL DEFAULT '0', - `poblacion` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, - `province_id` smallint(5) unsigned DEFAULT NULL, - `codPostal` varchar(8) COLLATE utf8_unicode_ci DEFAULT NULL, - `razonSocial` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL, - `contacto` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `mayorista` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', - `reexpedicion` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', - `invoice` tinyint(1) NOT NULL DEFAULT '1', - `notas` text COLLATE utf8_unicode_ci COMMENT 'Deprecated', - `notas_administracion` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', - `copiaFactura` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deprecated', - `retener` tinyint(1) NOT NULL DEFAULT '0', - `congelado` tinyint(1) NOT NULL DEFAULT '0', - `Id_Trabajador` int(11) DEFAULT NULL, - `credito` decimal(10,2) NOT NULL DEFAULT '0.00', - `cyc` double DEFAULT NULL, - `Id_Pais` mediumint(8) unsigned NOT NULL DEFAULT '1', - `activo` tinyint(1) NOT NULL DEFAULT '1', - `gestdoc_id` int(11) DEFAULT NULL, - `calidad` int(2) DEFAULT '11', - `pay_met_id` tinyint(3) unsigned NOT NULL DEFAULT '5', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `mail` tinyint(1) NOT NULL DEFAULT '1', - `chanel_id` smallint(6) DEFAULT NULL, - `vies` tinyint(4) NOT NULL DEFAULT '0', - `split_holland` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'eliminar', - `sepaFth` tinyint(1) DEFAULT '0' COMMENT 'campo para recibir los escritos de los clientes para el sepa', - `sepaVnl` tinyint(1) DEFAULT '0', - `coreFth` tinyint(1) DEFAULT '0', - `coreVnl` tinyint(1) DEFAULT '0', - `risk_calculated` date NOT NULL, - `coreVnh` tinyint(1) DEFAULT '0', - `real` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Define los clientes cuyas ventas hay que tener en cuenta en los calculos estadisticos.', - `clientes_tipo_id` int(11) NOT NULL DEFAULT '1', - `postcode_id` int(11) unsigned DEFAULT NULL, - `mail_address` int(11) DEFAULT NULL, - `codpos` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `creditInsurance` int(11) DEFAULT NULL, - `EYPBC` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Email\nYesterday\nPurchases\nBy\nConsigna', - `invoiceByAddress` tinyint(1) DEFAULT '0', - `cplusTerIdNifFk` int(11) NOT NULL DEFAULT '1' COMMENT 'OBSOLETO', - `isCreatedAsServed` tinyint(1) DEFAULT '0', - `hasInvoiceSimplified` tinyint(1) NOT NULL DEFAULT '0', - `iban` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `hasLcr` tinyint(1) NOT NULL DEFAULT '0', - `bankEntityFk` int(10) DEFAULT NULL, - `typeFk` varchar(20) CHARACTER SET utf8 NOT NULL DEFAULT 'normal', - PRIMARY KEY (`id_cliente`), - UNIQUE KEY `IF` (`if`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `Id_Pais` (`Id_Pais`), - KEY `pay_met_id` (`pay_met_id`), - KEY `canal_nuevo_cliente` (`chanel_id`), - KEY `Cuenta` (`Cuenta`), - KEY `province_id` (`province_id`), - KEY `default_address` (`default_address`), - KEY `Telefono` (`telefono`), - KEY `movil` (`movil`), - KEY `tipos_de_cliente_idx` (`clientes_tipo_id`), - KEY `codpos` (`codpos`,`codPostal`), - KEY `fk_Clientes_entity_idx` (`bankEntityFk`), - KEY `typeFk` (`typeFk`), - CONSTRAINT `Clientes_ibfk_1` FOREIGN KEY (`Id_Pais`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE, - CONSTRAINT `Clientes_ibfk_2` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Clientes_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `Clientes_ibfk_4` FOREIGN KEY (`default_address`) REFERENCES `Consignatarios` (`id_consigna`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `Clientes_ibfk_5` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, - 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=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 */ ; -/*!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 `client_beforeInsert` - BEFORE INSERT ON `Clientes` - FOR EACH ROW -BEGIN - DECLARE isAlreadyUsedIf BOOL; - - SELECT COUNT(*) INTO isAlreadyUsedIf - FROM Clientes - WHERE `IF` = TRIM(NEW.`IF`); - - IF isAlreadyUsedIf THEN - CALL util.throw('El NIF/CIF está repetido'); - END IF; - - CALL pbx.phone_isValid(NEW.telefono); - CALL pbx.phone_isValid(NEW.movil); - CALL pbx.phone_isValid(NEW.fax); - - SET NEW.cuenta = 4300000000 + NEW.Id_Cliente; -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 `client_beforeUpdate` - BEFORE UPDATE ON `Clientes` - FOR EACH ROW -BEGIN - DECLARE vText VARCHAR(255) DEFAULT NULL; - DECLARE isAlreadyUsedIf BOOL; - - SELECT (COUNT(*) > 1) INTO isAlreadyUsedIf - FROM Clientes - WHERE `IF` = TRIM(NEW.`IF`); - - IF isAlreadyUsedIf THEN - CALL util.throw('El NIF/CIF está repetido'); - END IF; - - -- Comprueba que el formato de los teléfonos es válido - - IF !(NEW.telefono <=> OLD.telefono) THEN - CALL pbx.phone_isValid(NEW.telefono); - END IF; - - IF !(NEW.movil <=> OLD.movil) THEN - CALL pbx.phone_isValid(NEW.movil); - END IF; - - IF !(NEW.fax <=> OLD.fax) THEN - CALL pbx.phone_isValid(NEW.fax); - END IF; - - IF NEW.pay_met_id = 4 AND NEW.Vencimiento = 0 THEN - SET NEW.Vencimiento = 5; - END IF; - - -- Avisar al comercial si ha llegado la documentación sepa/core - - IF NEW.sepavnl AND !OLD.sepavnl THEN - SET vText = 'Sepa de VNL'; - END IF; - - IF NEW.corevnl AND !OLD.corevnl THEN - SET vText = 'Core de VNL'; - END IF; - - IF vText IS NOT NULL - THEN - INSERT INTO mail(`to`, reply_to, subject, text) - SELECT - CONCAT(IF(ac.id,name, 'jgallego'), '@verdnatura.es'), - 'administracion@verdnatura.es', - CONCAT('Cliente ', NEW.Id_Cliente), - CONCAT('Recibida la documentación: ', vText) - FROM Trabajadores t - LEFT JOIN account.user u ON t.user_id = u.id AND active - LEFT JOIN account.account ac ON ac.id = u.id - WHERE t.Id_Trabajador = NEW.Id_Trabajador; - 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`.`client_afterUpdate` -AFTER UPDATE ON `Clientes` -FOR EACH ROW -BEGIN - IF !(NEW.default_address <=> OLD.default_address) THEN - UPDATE Consignatarios SET predeterminada = 0 - WHERE Id_cliente = NEW.Id_cliente; - - UPDATE Consignatarios SET predeterminada = 1 - WHERE Id_consigna = NEW.default_address; - 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 `Clientes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Clientes` AS SELECT + 1 AS `id_cliente`, + 1 AS `cliente`, + 1 AS `if`, + 1 AS `razonSocial`, + 1 AS `contacto`, + 1 AS `domicilio`, + 1 AS `poblacion`, + 1 AS `codPostal`, + 1 AS `telefono`, + 1 AS `movil`, + 1 AS `fax`, + 1 AS `real`, + 1 AS `e-mail`, + 1 AS `iban`, + 1 AS `vencimiento`, + 1 AS `Cuenta`, + 1 AS `RE`, + 1 AS `province_id`, + 1 AS `invoice`, + 1 AS `credito`, + 1 AS `Id_Pais`, + 1 AS `activo`, + 1 AS `gestdoc_id`, + 1 AS `calidad`, + 1 AS `pay_met_id`, + 1 AS `created`, + 1 AS `mail`, + 1 AS `chanel_id`, + 1 AS `sepaVnl`, + 1 AS `coreVnl`, + 1 AS `coreVnh`, + 1 AS `hasLcr`, + 1 AS `default_address`, + 1 AS `risk_calculated`, + 1 AS `clientes_tipo_id`, + 1 AS `mail_address`, + 1 AS `cplusTerIdNifFk`, + 1 AS `invoiceByAddress`, + 1 AS `contabilizado`, + 1 AS `congelado`, + 1 AS `creditInsurance`, + 1 AS `isCreatedAsServed`, + 1 AS `hasInvoiceSimplified`, + 1 AS `Id_Trabajador`, + 1 AS `vies`, + 1 AS `EYPBC`, + 1 AS `bankEntityFk`, + 1 AS `typeFk`, + 1 AS `recibo`, + 1 AS `cc`, + 1 AS `descuento`, + 1 AS `oficial`, + 1 AS `mayorista`, + 1 AS `reexpedicion`, + 1 AS `notas`, + 1 AS `notas_administracion`, + 1 AS `copiaFactura`, + 1 AS `retener`, + 1 AS `cyc`, + 1 AS `split_holland`, + 1 AS `sepaFth`, + 1 AS `coreFth`, + 1 AS `postcode_id`, + 1 AS `codpos`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Clientes_cedidos` @@ -50736,10 +54570,10 @@ CREATE TABLE `Clientes_cedidos` ( KEY `trabajador_fk_idx` (`Id_Trabajador_old`), KEY `new_trabajador_fk_idx` (`Id_Trabajador_new`), KEY `cliente_cedido_fk_idx` (`Id_Cliente`), - CONSTRAINT `cliente_cedido_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `cliente_cedido_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) 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=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'; +) ENGINE=InnoDB AUTO_INCREMENT=72 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 */; -- @@ -50778,7 +54612,7 @@ CREATE TABLE `Clientes_empresa` ( `fecha_fin` date NOT NULL, PRIMARY KEY (`Id_Clientes_empresa`), KEY `empresa_id_idx` (`empresa_id`), - CONSTRAINT `empresa_id` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION + CONSTRAINT `empresa_id` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=470507 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Empresa por defecto para crear los tickets'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -50794,7 +54628,7 @@ CREATE TABLE `Clientes_event` ( `quantity` tinyint(3) unsigned NOT NULL, `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `Clientes_event_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Clientes_event_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -50855,9 +54689,9 @@ CREATE TABLE `Colas` ( KEY `Id_Informe` (`Id_Informe`), KEY `Id_Prioridad` (`Id_Prioridad`), KEY `Id_Trabajador` (`Id_Trabajador`), - CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `Prioridades` (`Id_Prioridad`) ON UPDATE CASCADE, + CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `vn`.`queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=48490 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50932,19 +54766,34 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `Compres_mark` +-- Temporary table structure for view `Compres_mark` -- DROP TABLE IF EXISTS `Compres_mark`; +/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Compres_mark` AS SELECT + 1 AS `Id_Compra`, + 1 AS `comment`, + 1 AS `mark`, + 1 AS `odbc_date`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `Compres_mark__` +-- + +DROP TABLE IF EXISTS `Compres_mark__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Compres_mark` ( +CREATE TABLE `Compres_mark__` ( `Id_Compra` int(11) NOT NULL, `comment` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `mark` tinyint(1) DEFAULT NULL, `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`Id_Compra`), - CONSTRAINT `Compres_mark_ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Compres_mark___ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -50967,7 +54816,7 @@ CREATE TABLE `Compres_ok` ( KEY `Id_Movimiento` (`Id_Compra`), KEY `Id_Accion` (`Id_Accion`), CONSTRAINT `Compres_ok_ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=27972 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50982,7 +54831,7 @@ CREATE TABLE `Consignatarios` ( `Id_cliente` int(11) NOT NULL DEFAULT '0', `warehouse_id` smallint(6) unsigned DEFAULT '1', `domicilio` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `poblacion` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, + `poblacion` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `province_id` smallint(5) unsigned DEFAULT NULL, `codPostal` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `telefono` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -51008,10 +54857,10 @@ CREATE TABLE `Consignatarios` ( KEY `movil` (`movil`), KEY `CODPOSTAL` (`codPostal`), CONSTRAINT `Consignatarios_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - 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=28807 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON UPDATE CASCADE, + CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=29260 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 */ ; @@ -51139,7 +54988,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2743 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2753 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 */ ; @@ -51228,35 +55077,32 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `Cubos` +-- Temporary table structure for view `Cubos` -- DROP TABLE IF EXISTS `Cubos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Cubos` ( - `Id_Cubo` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `Volumen` decimal(10,2) DEFAULT '0.00', - `X` decimal(10,2) DEFAULT '0.00', - `Y` decimal(10,2) DEFAULT '0.00', - `Z` decimal(10,2) DEFAULT '0.00', - `Valor` decimal(10,2) DEFAULT '0.00', - `Retornable` tinyint(1) NOT NULL DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `idCubos_Retorno` int(11) DEFAULT NULL, - `Bajan` int(11) DEFAULT NULL, - `Suben` int(11) DEFAULT NULL, - `Base` decimal(10,2) DEFAULT NULL, - `item_id` int(11) DEFAULT NULL, - `pvp` decimal(10,2) NOT NULL, - `box` tinyint(1) NOT NULL DEFAULT '0', - `bultoCubico` decimal(10,2) DEFAULT NULL, - `costeRetorno` decimal(10,2) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`Id_Cubo`), - KEY `Article` (`item_id`), - CONSTRAINT `Article` FOREIGN KEY (`item_id`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Cubos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Cubos` AS SELECT + 1 AS `Id_Cubo`, + 1 AS `Volumen`, + 1 AS `X`, + 1 AS `Y`, + 1 AS `Z`, + 1 AS `Retornable`, + 1 AS `odbc_date`, + 1 AS `item_id`, + 1 AS `pvp`, + 1 AS `bultoCubico`, + 1 AS `Valor`, + 1 AS `idCubos_Retorno`, + 1 AS `Bajan`, + 1 AS `Suben`, + 1 AS `Base`, + 1 AS `box`, + 1 AS `costeRetorno`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Cubos_Retorno` @@ -51295,7 +55141,7 @@ CREATE TABLE `Enlaces Facturas` ( `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), - CONSTRAINT `Enlaces@0020Facturas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE + CONSTRAINT `Enlaces@0020Facturas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=23889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -51366,7 +55212,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=3812681 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3888286 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51384,7 +55230,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=245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51576,167 +55422,41 @@ CREATE TABLE `Extractos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Facturas` +-- Temporary table structure for view `Facturas` -- DROP TABLE IF EXISTS `Facturas`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Facturas` ( - `factura_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Factura` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `Serie` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `Importe` decimal(12,2) DEFAULT '0.00', - `Vencimiento` datetime DEFAULT NULL, - `Id_Banco` int(11) DEFAULT NULL, - `Id_Cliente` int(11) DEFAULT '0', - `Id_Remesa` int(11) DEFAULT NULL, - `Remesar` tinyint(1) NOT NULL DEFAULT '0', - `BI7` decimal(12,2) DEFAULT '0.00', - `BI16` decimal(12,2) DEFAULT '0.00', - `RE1` decimal(12,2) DEFAULT '0.00', - `RE4` decimal(12,2) DEFAULT '0.00', - `IVA7` decimal(12,2) DEFAULT '0.00', - `IVA16` decimal(12,2) DEFAULT '0.00', - `Id_Trabajador` int(11) DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `liquidacion` smallint(6) DEFAULT '0', - `pdf` tinyint(3) unsigned NOT NULL DEFAULT '0', - `booked` date DEFAULT NULL, - `cplusInvoiceType477Fk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusTaxBreakFk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusSubjectOpFk` int(10) unsigned NOT NULL DEFAULT '1', - `cplusTrascendency477Fk` int(10) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`factura_id`,`Id_Factura`), - UNIQUE KEY `Id_Factura` (`Id_Factura`), - KEY `Id_Banco` (`Id_Banco`), - KEY `Id_Cliente` (`Id_Cliente`), - KEY `Id_Remesa` (`Id_Remesa`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `empresa_id` (`empresa_id`), - KEY `Fecha` (`Fecha`), - KEY `Facturas_ibfk_2_idx` (`cplusInvoiceType477Fk`), - KEY `Facturas_ibfk_3_idx` (`cplusSubjectOpFk`), - KEY `Facturas_ibfk_4_idx` (`cplusTaxBreakFk`), - KEY `Facturas_ibfk_5_idx` (`cplusTrascendency477Fk`), - KEY `Facturas_idx_Vencimiento` (`Vencimiento`), - CONSTRAINT `Facturas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Facturas_ibfk_2` FOREIGN KEY (`cplusInvoiceType477Fk`) REFERENCES `vn`.`cplusInvoiceType477` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Facturas_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `vn`.`cplusSubjectOp` (`id`) ON UPDATE CASCADE, - 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=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 */ ; -/*!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 `FacturasBeforeInsert` -BEFORE INSERT ON `Facturas` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one -BEGIN - - DECLARE v_Id_Factura_serie CHAR(9) DEFAULT '0000001'; - DECLARE v_Id_Factura INT; - DECLARE max_id, intLast, intProv INT; - - SELECT IFNULL(MAX(factura_id),0) into max_id - from Facturas - WHERE Serie LIKE NEW.Serie - AND ((Year(NEW.Fecha) = Year(Fecha) - AND empresa_id = NEW.empresa_id)); - - IF max_id THEN - - SELECT right(max(Id_Factura), LENGTH(Id_Factura)-1) + 1 - into v_Id_Factura_serie - from Facturas - WHERE Serie LIKE NEW.Serie - AND ((Year(NEW.Fecha) = Year(Fecha) - AND length(Id_Factura) > 6 - AND empresa_id = NEW.empresa_id) /*OR (NEW.Serie LIKE 'B' AND length(Id_Factura) > 7)*/ ); - ELSE - SELECT CONCAT(digito_factura,RIGHT(YEAR(CURDATE()),1),'00001') INTO v_Id_Factura_serie - FROM empresa WHERE id = NEW.empresa_id; - -/*Primer digito la empresa, segundo el año, despues la numeracion correlativa con 5 digitos*/ - - END IF; - -SELECT CONCAT(NEW.serie, lpad(v_Id_Factura_serie,7,'0')) into v_Id_Factura_serie; -SET NEW.Id_Factura = v_Id_Factura_serie; - - END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`FacturasAfterInsert` -AFTER INSERT ON `Facturas` -FOR EACH ROW - CALL bi.customer_risk_update (NEW.Id_Cliente, NEW.empresa_id, NEW.Importe) */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`FacturasBeforeUpdate` -BEFORE UPDATE ON `Facturas` -FOR EACH ROW -BEGIN - CALL bi.customer_risk_update (OLD.Id_Cliente, OLD.empresa_id, -OLD.Importe); - CALL bi.customer_risk_update (NEW.Id_Cliente, NEW.empresa_id, NEW.Importe); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`FacturasBeforeDelete` -BEFORE DELETE ON `Facturas` -FOR EACH ROW - CALL bi.customer_risk_update (OLD.Id_Cliente, OLD.empresa_id, -OLD.Importe) */;; -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 `Facturas`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Facturas` AS SELECT + 1 AS `factura_id`, + 1 AS `Id_Factura`, + 1 AS `Serie`, + 1 AS `Fecha`, + 1 AS `Importe`, + 1 AS `Id_Cliente`, + 1 AS `odbc_date`, + 1 AS `empresa_id`, + 1 AS `Vencimiento`, + 1 AS `booked`, + 1 AS `Id_Banco`, + 1 AS `cplusInvoiceType477Fk`, + 1 AS `cplusTaxBreakFk`, + 1 AS `cplusSubjectOpFk`, + 1 AS `cplusTrascendency477Fk`, + 1 AS `pdf`, + 1 AS `Id_Remesa`, + 1 AS `Remesar`, + 1 AS `BI7`, + 1 AS `BI16`, + 1 AS `RE1`, + 1 AS `RE4`, + 1 AS `IVA7`, + 1 AS `IVA16`, + 1 AS `Id_Trabajador`, + 1 AS `liquidacion`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Familias` @@ -51768,23 +55488,21 @@ CREATE TABLE `Forms` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Gastos` +-- Temporary table structure for view `Gastos` -- DROP TABLE IF EXISTS `Gastos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Gastos` ( - `Id_Gasto` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `iva_tipo_id` tinyint(4) NOT NULL, - `Gasto` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `conbase` tinyint(4) NOT NULL DEFAULT '1', - `isWithheld` tinyint(4) NOT NULL DEFAULT '0', - `isForSale` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY (`Id_Gasto`,`iva_tipo_id`), - KEY `iva_tipo_id` (`iva_tipo_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Gastos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Gastos` AS SELECT + 1 AS `Id_Gasto`, + 1 AS `iva_tipo_id`, + 1 AS `Gasto`, + 1 AS `isWithheld`, + 1 AS `conbase`, + 1 AS `isForSale`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `Greuges` @@ -51870,23 +55588,20 @@ CREATE TABLE `Informes` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Intrastat` +-- Temporary table structure for view `Intrastat` -- DROP TABLE IF EXISTS `Intrastat`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Intrastat` ( - `Codintrastat` int(8) unsigned zerofill NOT NULL, - `Definicion` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `import` tinyint(4) NOT NULL DEFAULT '0', - `iva_group_id` tinyint(3) unsigned NOT NULL DEFAULT '2', - `iva_codigo_id` tinyint(2) unsigned NOT NULL DEFAULT '64', - PRIMARY KEY (`Codintrastat`), - KEY `iva_group_id` (`iva_group_id`), - CONSTRAINT `Intrastat_ibfk_1` FOREIGN KEY (`iva_group_id`) REFERENCES `iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Intrastat`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Intrastat` AS SELECT + 1 AS `Codintrastat`, + 1 AS `Definicion`, + 1 AS `iva_group_id`, + 1 AS `iva_codigo_id`, + 1 AS `import`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Jefes` @@ -51949,127 +55664,28 @@ CREATE TABLE `Monitoring` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Movimientos` +-- Temporary table structure for view `Movimientos` -- DROP TABLE IF EXISTS `Movimientos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos` ( - `Id_Movimiento` int(11) NOT NULL AUTO_INCREMENT, - `Id_Article` int(11) NOT NULL, - `Id_Ticket` int(11) NOT NULL, - `Concepte` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Cantidad` decimal(10,2) NOT NULL DEFAULT '0.00', - `quantity` double(9,1) DEFAULT NULL, - `Preu` decimal(10,2) DEFAULT '0.00', - `Descuento` tinyint(2) unsigned NOT NULL DEFAULT '0', - `CostFixat` decimal(10,2) NOT NULL DEFAULT '0.00', - `Reservado` tinyint(1) NOT NULL DEFAULT '0', - `OK` tinyint(1) NOT NULL DEFAULT '0', - `PrecioFijado` tinyint(1) NOT NULL DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`Id_Movimiento`), - KEY `Id_Ticket` (`Id_Ticket`), - 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=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 */ ; -/*!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 `sale_afterInsert` - AFTER INSERT ON `Movimientos` - FOR EACH ROW -BEGIN - CALL stock.log_add('sale', NEW.Id_Movimiento, 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 `sale_beforeUpdate` - BEFORE UPDATE ON `Movimientos` - FOR EACH ROW -BEGIN - IF NEW.Descuento > 100 THEN - SET NEW.Descuento = 0; - 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 `sale_afterUpdate` - AFTER UPDATE ON `Movimientos` - FOR EACH ROW -BEGIN - IF !(NEW.Id_Movimiento <=> OLD.Id_Movimiento) - OR !(NEW.Id_Ticket <=> OLD.Id_Ticket) - OR !(NEW.Id_Article <=> OLD.Id_Article) - OR !(NEW.Cantidad <=> OLD.Cantidad) - OR !(NEW.odbc_date <=> OLD.odbc_date) - OR !(NEW.OK <=> OLD.OK) THEN - CALL stock.log_add('sale', NEW.Id_Movimiento, OLD.Id_Movimiento); - END IF; - - IF !(OLD.Id_Ticket <=> NEW.Id_Ticket) THEN - UPDATE Ordenes SET ticketFk = NEW.Id_Ticket - WHERE Id_Movimiento = NEW.Id_Movimiento; - 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 `sale_afterDelete` - AFTER DELETE ON `Movimientos` - FOR EACH ROW -BEGIN - CALL stock.log_add('sale', NULL, OLD.Id_Movimiento); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `Movimientos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Movimientos` AS SELECT + 1 AS `Id_Movimiento`, + 1 AS `Id_Article`, + 1 AS `Id_Ticket`, + 1 AS `Concepte`, + 1 AS `Cantidad`, + 1 AS `Preu`, + 1 AS `Descuento`, + 1 AS `Reservado`, + 1 AS `OK`, + 1 AS `odbc_date`, + 1 AS `CostFixat`, + 1 AS `PrecioFijado`, + 1 AS `quantity`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Movimientos_avisar` @@ -52084,92 +55700,57 @@ CREATE TABLE `Movimientos_avisar` ( PRIMARY KEY (`Id_Movimiento`), KEY `Movimiento` (`Id_Movimiento`), KEY `Remitente` (`Id_Remitente`), - CONSTRAINT `Id_Movimientos_avisar_fk` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Id_Movimientos_avisar_fk` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`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 `Movimientos_checked` +-- Temporary table structure for view `Movimientos_checked` -- DROP TABLE IF EXISTS `Movimientos_checked`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_checked` ( - `Id_Movimiento` int(11) NOT NULL, - `checked` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`Id_Movimiento`), - CONSTRAINT `fk_Movimientos_checked_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Movimientos_checked`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Movimientos_checked` AS SELECT + 1 AS `Id_Movimiento`, + 1 AS `checked`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Movimientos_componentes` +-- Temporary table structure for view `Movimientos_componentes` -- DROP TABLE IF EXISTS `Movimientos_componentes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_componentes` ( - `Id_Movimiento` int(11) NOT NULL, - `Id_Componente` int(11) NOT NULL, - `Valor` double NOT NULL, - `greuge` tinyint(4) NOT NULL DEFAULT '0', - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`Id_Movimiento`,`Id_Componente`), - KEY `fk_mov_comp_idx` (`Id_Componente`), - CONSTRAINT `mc_fk1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `mc_fk2` FOREIGN KEY (`Id_Componente`) REFERENCES `bi`.`tarifa_componentes` (`Id_Componente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Movimientos_componentes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Movimientos_componentes` AS SELECT + 1 AS `Id_Movimiento`, + 1 AS `Id_Componente`, + 1 AS `Valor`, + 1 AS `created`, + 1 AS `greuge`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Movimientos_mark` +-- Temporary table structure for view `Movimientos_mark` -- DROP TABLE IF EXISTS `Movimientos_mark`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_mark` ( - `Id_Movimiento` int(11) NOT NULL, - `valor` tinyint(3) unsigned NOT NULL DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `original_quantity` double DEFAULT NULL, - `Id_Trabajador` int(11) NOT NULL, - `Id_Accion` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `Id_Movimiento_mark` int(11) NOT NULL AUTO_INCREMENT, - `stateFk` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`Id_Movimiento_mark`), - UNIQUE KEY `stateFk_UNIQUE` (`stateFk`,`Id_Movimiento`), - KEY `Id_Movimiento` (`Id_Movimiento`), - KEY `fgnStateFk_idx` (`stateFk`), - CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) 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 */ ; -/*!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`.`Movimientos_mark_BEFORE_INSERT` BEFORE INSERT ON `Movimientos_mark` FOR EACH ROW -BEGIN - IF(NEW.stateFk = 14) THEN - SET NEW.Id_Accion = 3; - END IF; - - IF(NEW.stateFk = 8) THEN - SET NEW.Id_Accion = 4; - 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 `Movimientos_mark`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Movimientos_mark` AS SELECT + 1 AS `Id_Movimiento`, + 1 AS `valor`, + 1 AS `odbc_date`, + 1 AS `original_quantity`, + 1 AS `Id_Trabajador`, + 1 AS `Id_Accion`, + 1 AS `Id_Movimiento_mark`, + 1 AS `stateFk`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Movimientos_revisar` @@ -52187,7 +55768,7 @@ CREATE TABLE `Movimientos_revisar` ( PRIMARY KEY (`Id_Movimiento`), KEY `Remitente` (`Id_Remitente`), KEY `Destinatario` (`Id_Destinatario`), - CONSTRAINT `Movimientos_revisar_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Movimientos_revisar_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52206,132 +55787,55 @@ CREATE TABLE `Objetivos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Ordenes` +-- Temporary table structure for view `Ordenes` -- DROP TABLE IF EXISTS `Ordenes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Ordenes` ( - `Id_ORDEN` int(11) NOT NULL AUTO_INCREMENT, - `ORDEN` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `datORDEN` datetime DEFAULT NULL, - `datTICKET` datetime DEFAULT NULL, - `CodVENDEDOR` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `CodCOMPRADOR` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'NOE', - `CANTIDAD` int(11) DEFAULT NULL, - `PRECIOMAX` double DEFAULT NULL, - `PREU` double DEFAULT NULL, - `Id_ARTICLE` double DEFAULT NULL, - `Id_CLIENTE` int(11) DEFAULT NULL, - `COMENTARIO` longtext COLLATE utf8_unicode_ci, - `OK` tinyint(1) NOT NULL DEFAULT '0', - `TOTAL` int(11) DEFAULT NULL, - `datCOMPRA` datetime DEFAULT NULL, - `KO` tinyint(1) NOT NULL DEFAULT '0', - `Id_Movimiento` int(11) DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `isOk` tinyint(1) DEFAULT NULL, - `requesterFk` int(11) DEFAULT NULL, - `atenderFk` int(11) DEFAULT NULL, - `ticketFk` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_ORDEN`), - UNIQUE KEY `Id_Movimiento_UNIQUE` (`Id_Movimiento`), - KEY `Id_ARTICLE` (`Id_ARTICLE`), - KEY `Id_CLIENTE` (`Id_CLIENTE`), - KEY `Id_Comprador` (`CodCOMPRADOR`), - KEY `Id_Movimiento` (`Id_Movimiento`), - KEY `Id_Vendedor` (`CodVENDEDOR`), - KEY `fgnRequester_idx` (`requesterFk`), - KEY `fgnAtender_idx` (`atenderFk`), - KEY `fgnTicket_idx` (`ticketFk`), - CONSTRAINT `fgbMovimiento` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE SET NULL ON UPDATE CASCADE, - 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=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 */ ; -/*!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`.`Ordenes_BEFORE_INSERT` BEFORE INSERT ON `Ordenes` FOR EACH ROW -BEGIN - IF NEW.ticketFk IS NULL THEN - SET NEW.ticketFk = (SELECT m.Id_Ticket FROM Movimientos m WHERE m.Id_Movimiento = NEW.Id_Movimiento); - END IF; - - IF NEW.requesterFk IS NULL THEN - SET NEW.requesterFk = (SELECT t.Id_Trabajador FROM Trabajadores t WHERE t.CodigoTrabajador = NEW.CodVENDEDOR); - END IF; - - IF NEW.atenderFk IS NULL THEN - SET NEW.atenderFk = (SELECT t.Id_Trabajador FROM Trabajadores t WHERE t.CodigoTrabajador = NEW.CodCOMPRADOR); - 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 = 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`.`Ordenes_BEFORE_UPDATE` BEFORE UPDATE ON `Ordenes` FOR EACH ROW -BEGIN - IF NEW.Id_Movimiento <> OLD.Id_Movimiento THEN - SET NEW.ticketFk = (SELECT m.Id_Ticket FROM Movimientos m WHERE m.Id_Movimiento = NEW.Id_Movimiento); - END IF; - - IF NEW.CodVENDEDOR <> OLD.CodVENDEDOR THEN - SET NEW.requesterFk = (SELECT t.Id_Trabajador FROM Trabajadores t WHERE t.CodigoTrabajador = NEW.CodVENDEDOR); - END IF; - - IF NEW.CodCOMPRADOR <> OLD.CodCOMPRADOR THEN - SET NEW.atenderFk = (SELECT t.Id_Trabajador FROM Trabajadores t WHERE t.CodigoTrabajador = NEW.CodCOMPRADOR); - 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 `Ordenes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Ordenes` AS SELECT + 1 AS `Id_ORDEN`, + 1 AS `ORDEN`, + 1 AS `requesterFk`, + 1 AS `atenderFk`, + 1 AS `CANTIDAD`, + 1 AS `Id_ARTICLE`, + 1 AS `PRECIOMAX`, + 1 AS `isOk`, + 1 AS `Id_Movimiento`, + 1 AS `ticketFk`, + 1 AS `COMENTARIO`, + 1 AS `odbc_date`, + 1 AS `datORDEN`, + 1 AS `datTICKET`, + 1 AS `CodVENDEDOR`, + 1 AS `CodCOMPRADOR`, + 1 AS `PREU`, + 1 AS `Id_CLIENTE`, + 1 AS `OK`, + 1 AS `TOTAL`, + 1 AS `datCOMPRA`, + 1 AS `KO`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Origen` +-- Temporary table structure for view `Origen` -- DROP TABLE IF EXISTS `Origen`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Origen` ( - `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, - `Abreviatura` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `Origen` varchar(20) COLLATE utf8_unicode_ci NOT NULL, - `warehouse_id` smallint(5) unsigned DEFAULT '4', - `bandera` blob, - `nl` tinyint(4) NOT NULL DEFAULT '0', - `Id_Paises` mediumint(8) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `Abreviatura` (`Abreviatura`), - KEY `warehouse_id` (`warehouse_id`), - KEY `Id_Paises` (`Id_Paises`), - CONSTRAINT `Origen_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Origen`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Origen` AS SELECT + 1 AS `id`, + 1 AS `Abreviatura`, + 1 AS `Origen`, + 1 AS `Id_Paises`, + 1 AS `warehouse_id`, + 1 AS `bandera`, + 1 AS `nl`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Pagares` @@ -52353,114 +55857,31 @@ 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=2877 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Paises` +-- Temporary table structure for view `Paises` -- DROP TABLE IF EXISTS `Paises`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Paises` ( - `Id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Pais` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `CEE` tinyint(1) NOT NULL DEFAULT '1', - `Codigo` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `Id_Moneda` tinyint(3) unsigned NOT NULL DEFAULT '1', - `Id_Paisreal` mediumint(8) unsigned NOT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', - `nst_geo_id` int(11) DEFAULT NULL, - `nst_name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `geoFk` int(11) DEFAULT NULL, - `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT '0', - `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', - `ibanLength` tinyint(4) DEFAULT NULL, - PRIMARY KEY (`Id`), - 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 */ ; +/*!50001 DROP VIEW IF EXISTS `Paises`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Paises` AS SELECT + 1 AS `Id`, + 1 AS `Pais`, + 1 AS `CEE`, + 1 AS `isUeeMember`, + 1 AS `Codigo`, + 1 AS `Id_Moneda`, + 1 AS `Id_Paisreal`, + 1 AS `geoFk`, + 1 AS `ibanLength`, + 1 AS `hasDailyInvoice`, + 1 AS `nst_geo_id`, + 1 AS `nst_name`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Permisos` @@ -52475,7 +55896,7 @@ CREATE TABLE `Permisos` ( `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', PRIMARY KEY (`Id_Grupo`,`Id_Trabajador`), KEY `empresa_id` (`empresa_id`), - CONSTRAINT `Permisos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Permisos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Permisos_ibfk_2` FOREIGN KEY (`Id_Grupo`) REFERENCES `Grupos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52496,100 +55917,82 @@ CREATE TABLE `PreciosEspeciales` ( UNIQUE KEY `Id_Cliente_2` (`Id_Cliente`,`Id_Article`), KEY `Id_Article` (`Id_Article`), KEY `Id_Cliente` (`Id_Cliente`), - CONSTRAINT `sp_article_id` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE, - CONSTRAINT `sp_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, - CONSTRAINT `{01A99AF1-3D3F-4B15-AC0C-C7A834F319A3}` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `{EE4ADEF6-0AC6-401F-B7C4-D797972FC065}` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE + CONSTRAINT `sp_article_id` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `sp_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `{01A99AF1-3D3F-4B15-AC0C-C7A834F319A3}` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `{EE4ADEF6-0AC6-401F-B7C4-D797972FC065}` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=708 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Prioridades` +-- Temporary table structure for view `Prioridades` -- DROP TABLE IF EXISTS `Prioridades`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Prioridades` ( - `Id_Prioridad` tinyint(3) unsigned NOT NULL DEFAULT '0', - `Prioridad` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`Id_Prioridad`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Prioridades`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Prioridades` AS SELECT + 1 AS `Id_Prioridad`, + 1 AS `Prioridad`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Proveedores` +-- Temporary table structure for view `Proveedores` -- DROP TABLE IF EXISTS `Proveedores`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores` ( - `Id_Proveedor` int(11) NOT NULL AUTO_INCREMENT, - `Proveedor` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `cuenta` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `Domicilio` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `CP` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `Localidad` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `province_id` smallint(5) unsigned DEFAULT NULL, - `pais_id` mediumint(8) unsigned DEFAULT NULL, - `NIF` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `oficial` tinyint(1) NOT NULL DEFAULT '1', - `Agricola` tinyint(1) NOT NULL DEFAULT '0', - `cuentaret` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `Telefono` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, - `Fax` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL, - `ComisionProveedor` float NOT NULL DEFAULT '0', - `Alias` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `pay_met_id` tinyint(3) unsigned NOT NULL, - `pay_day` tinyint(4) unsigned DEFAULT NULL, - `pay_dem_id` tinyint(3) unsigned NOT NULL DEFAULT '7', - `odbc_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `serious` tinyint(1) unsigned zerofill DEFAULT '1', - `notas` text COLLATE utf8_unicode_ci, - `postcode_id` int(11) unsigned DEFAULT NULL, - `codpos` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `active` tinyint(4) DEFAULT '1', - PRIMARY KEY (`Id_Proveedor`), - UNIQUE KEY `cuenta` (`cuenta`), - UNIQUE KEY `NIF` (`NIF`), - KEY `pais_id` (`pais_id`), - KEY `pay_met_id` (`pay_met_id`), - KEY `province_id` (`province_id`), - KEY `pay_dem_id` (`pay_dem_id`), - KEY `codpos` (`codpos`,`CP`), - CONSTRAINT `Id_Pais` FOREIGN KEY (`pais_id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE, - 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=2873 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Proveedores`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Proveedores` AS SELECT + 1 AS `Id_Proveedor`, + 1 AS `Proveedor`, + 1 AS `cuenta`, + 1 AS `pais_id`, + 1 AS `NIF`, + 1 AS `Agricola`, + 1 AS `Telefono`, + 1 AS `cuentaret`, + 1 AS `ComisionProveedor`, + 1 AS `odbc_time`, + 1 AS `postcode_id`, + 1 AS `active`, + 1 AS `Domicilio`, + 1 AS `Localidad`, + 1 AS `province_id`, + 1 AS `codpos`, + 1 AS `pay_met_id`, + 1 AS `pay_dem_id`, + 1 AS `Alias`, + 1 AS `CP`, + 1 AS `oficial`, + 1 AS `Fax`, + 1 AS `pay_day`, + 1 AS `serious`, + 1 AS `notas`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Proveedores_account` +-- Temporary table structure for view `Proveedores_account` -- DROP TABLE IF EXISTS `Proveedores_account`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_account` ( - `Id_Proveedores_account` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Proveedor` int(11) NOT NULL, - `IBAN` varchar(30) CHARACTER SET utf8 DEFAULT NULL, - `office` varchar(4) CHARACTER SET utf8 DEFAULT NULL, - `DC` varchar(2) CHARACTER SET utf8 DEFAULT NULL, - `number` varchar(10) CHARACTER SET utf8 DEFAULT NULL, - `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `bic_sufix` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', - `entity_id` int(10) DEFAULT NULL, - `Id_Banco` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Proveedores_account`), - KEY `fk_proveedores_proveedores_account_idx` (`Id_Proveedor`), - 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=841 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Proveedores_account`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Proveedores_account` AS SELECT + 1 AS `Id_Proveedores_account`, + 1 AS `Id_Proveedor`, + 1 AS `IBAN`, + 1 AS `entity_id`, + 1 AS `office`, + 1 AS `DC`, + 1 AS `number`, + 1 AS `description`, + 1 AS `Id_Banco`, + 1 AS `bic_sufix`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Proveedores_cargueras` @@ -52601,7 +56004,7 @@ DROP TABLE IF EXISTS `Proveedores_cargueras`; CREATE TABLE `Proveedores_cargueras` ( `Id_Proveedor` int(11) NOT NULL, PRIMARY KEY (`Id_Proveedor`), - CONSTRAINT `proveedores_cargueras_fk1` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `proveedores_cargueras_fk1` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla de espcializacion para señalar las compañias que prestan servicio de transitario'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52620,7 +56023,7 @@ CREATE TABLE `Proveedores_comunicados` ( PRIMARY KEY (`id`), KEY `Proveedor` (`Id_Proveedor`), KEY `Escrito` (`escrito_id`), - CONSTRAINT `Proveedores_comunicados_ibfk_3` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, + CONSTRAINT `Proveedores_comunicados_ibfk_3` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `Proveedores_comunicados_ibfk_4` FOREIGN KEY (`escrito_id`) REFERENCES `Proveedores_escritos` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=173 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52679,10 +56082,10 @@ CREATE TABLE `Recibos` ( KEY `empresa_id` (`empresa_id`), KEY `clientDate` (`Id_Cliente`,`Fechacobro`), KEY `id_factura` (`Id_Factura`), - 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=591752 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=599651 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 */ ; @@ -52773,7 +56176,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2747 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2757 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52791,9 +56194,9 @@ CREATE TABLE `Remesas` ( PRIMARY KEY (`Id_Remesa`), KEY `Id_Banco` (`Banco`), 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=1335 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=1346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52818,92 +56221,34 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=983 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Rutas` +-- Temporary table structure for view `Rutas` -- DROP TABLE IF EXISTS `Rutas`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Rutas` ( - `Id_Ruta` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Trabajador` int(10) unsigned DEFAULT NULL, - `Fecha` date NOT NULL, - `Id_Vehiculo` int(10) unsigned DEFAULT NULL, - `Id_Agencia` int(11) DEFAULT NULL, - `Hora` datetime DEFAULT NULL, - `ok` tinyint(1) unsigned NOT NULL DEFAULT '0', - `km_start` mediumint(9) NOT NULL, - `km_end` mediumint(9) NOT NULL, - `date_start` datetime NOT NULL, - `date_end` datetime NOT NULL, - `gestdoc_id` int(11) DEFAULT NULL, - `cost` double unsigned DEFAULT NULL, - `m3` decimal(10,1) unsigned DEFAULT NULL, - `description` text COLLATE utf8_unicode_ci, - PRIMARY KEY (`Id_Ruta`), - KEY `Id_Agencia` (`Id_Agencia`), - 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=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 */ ; -/*!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`.`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(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 ; -/*!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 = '' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `Rutas_au` AFTER UPDATE ON `Rutas` FOR EACH ROW -BEGIN - - IF IFNULL(NEW.gestdoc_id,0) <> IFNULL(OLD.gestdoc_id,0) AND NEW.gestdoc_id > 0 THEN - -- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets - - -- Inserta el gestdoc en todos los tickets de la ruta - INSERT INTO tickets_gestdoc(Id_Ticket,gestdoc_id) - SELECT Id_Ticket, NEW.gestdoc_id FROM Tickets WHERE Id_Ruta = NEW.Id_Ruta - ON DUPLICATE KEY UPDATE gestdoc_id = NEW.gestdoc_id; - - -- Update del firmado - UPDATE Tickets t JOIN tickets_gestdoc tg ON t.Id_Ticket = tg.Id_Ticket - SET Firmado = 1 WHERE t.Id_Ruta = NEW.Id_Ruta; - 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 `Rutas`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Rutas` AS SELECT + 1 AS `Id_Ruta`, + 1 AS `Id_Trabajador`, + 1 AS `Fecha`, + 1 AS `Id_Vehiculo`, + 1 AS `Id_Agencia`, + 1 AS `Hora`, + 1 AS `ok`, + 1 AS `km_start`, + 1 AS `km_end`, + 1 AS `date_start`, + 1 AS `date_end`, + 1 AS `gestdoc_id`, + 1 AS `cost`, + 1 AS `m3`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Rutas_Master` @@ -52934,7 +56279,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=118 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52957,7 +56302,7 @@ CREATE TABLE `Rutas_dits` ( KEY `index3` (`Id_Ticket`), KEY `index4` (`Id_Trabajador`), CONSTRAINT `fk_Id_Trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `fk_Id_ruta` FOREIGN KEY (`Id_Ticket`) REFERENCES `Rutas` (`Id_Ruta`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_Id_ruta` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_action_dits` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=300164 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -52982,7 +56327,7 @@ CREATE TABLE `Rutas_monitor` ( `dockFk` int(11) DEFAULT NULL, PRIMARY KEY (`Id_Ruta`), KEY `Rutas_monitor_fk_2_idx` (`dockFk`), - CONSTRAINT `Rutas_monitor_fk_1` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Rutas_monitor_fk_1` FOREIGN KEY (`Id_Ruta`) REFERENCES `vn`.`route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Rutas_monitor_fk_2` FOREIGN KEY (`dockFk`) REFERENCES `dock` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Permite ubicar y controlar el estado de preparacion de las rutas'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -53023,9 +56368,9 @@ CREATE TABLE `Saldos_Prevision` ( KEY `Fecha_indice` (`Fecha`), KEY `banco_prevision_idx` (`Id_Banco`), 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=320 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; + CONSTRAINT `banco_prevision` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, + CONSTRAINT `empresa_prevision` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=336 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 */; -- @@ -53060,7 +56405,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=365796 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=367273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53078,7 +56423,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=36877 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36950 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53103,197 +56448,52 @@ CREATE TABLE `Stockcontrol` ( KEY `Id_Article` (`Id_Article`), KEY `Id_Remitente` (`Id_Remitente`), KEY `Id_Solver` (`Id_Solver`), - CONSTRAINT `Stockcontrol_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Stockcontrol_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_2` FOREIGN KEY (`Id_Remitente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_3` FOREIGN KEY (`Id_Solver`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=24061 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Tickets` +-- Temporary table structure for view `Tickets` -- DROP TABLE IF EXISTS `Tickets`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tickets` ( - `Id_Ticket` int(11) NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL DEFAULT '0', - `warehouse_id` smallint(6) unsigned NOT NULL DEFAULT '1', - `Fecha` datetime NOT NULL, - `Alias` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Notas` longtext COLLATE utf8_unicode_ci, - `Factura` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `factura_id` int(10) unsigned DEFAULT NULL COMMENT 'eliminar', - `Anotadoencaja` tinyint(1) NOT NULL DEFAULT '0', - `Id_Consigna` int(11) NOT NULL DEFAULT '0', - `Id_Trabajador` int(11) DEFAULT NULL, - `Observaciones` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'eliminar', - `Firmado` tinyint(1) NOT NULL DEFAULT '0', - `Etiquetasemitidas` tinyint(1) NOT NULL DEFAULT '0', - `PedidoImpreso` tinyint(1) NOT NULL DEFAULT '0', - `Bultos` smallint(10) unsigned DEFAULT '0', - `Localizacion` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, - `Hora` int(11) DEFAULT '0', - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `blocked` tinyint(1) NOT NULL DEFAULT '1', - `Solucion` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `Id_Ruta` int(10) unsigned DEFAULT NULL, - `Prioridad` tinyint(3) unsigned DEFAULT NULL, - `priority` tinyint(1) unsigned NOT NULL DEFAULT '1', - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `Id_Agencia` int(11) DEFAULT NULL, - `landing` date DEFAULT NULL, - `boxed` tinyint(2) NOT NULL DEFAULT '0', - `isDeleted` tinyint(2) NOT NULL DEFAULT '0', - `zoneFk` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Ticket`), - KEY `Id_Cliente` (`Id_Cliente`), - KEY `Id_Consigna` (`Id_Consigna`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `warehouse_id` (`warehouse_id`), - KEY `empresa_id` (`empresa_id`), - KEY `Id_Agencia` (`Id_Agencia`), - KEY `Factura` (`Factura`), - KEY `Id_Ruta` (`Id_Ruta`), - KEY `warehouse_date` (`warehouse_id`,`Fecha`), - KEY `Fecha` (`Fecha`,`Id_Cliente`), - KEY `tickets_zone_fk_idx` (`zoneFk`), - CONSTRAINT `Tickets_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Tickets_ibfk_5` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Tickets_ibfk_6` FOREIGN KEY (`Id_Consigna`) REFERENCES `Consignatarios` (`id_consigna`) ON UPDATE CASCADE, - CONSTRAINT `Tickets_ibfk_8` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`), - CONSTRAINT `Tickets_ibfk_9` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON UPDATE CASCADE, - CONSTRAINT `ticket_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, - CONSTRAINT `tickets_fk10` FOREIGN KEY (`Factura`) REFERENCES `Facturas` (`Id_Factura`) ON UPDATE CASCADE, - CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON UPDATE CASCADE -) 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 */ ; -/*!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 `ticket_afterInsert` - AFTER INSERT ON `Tickets` - FOR EACH ROW -BEGIN - DECLARE vClientType VARCHAR(255); - DECLARE vStateCode VARCHAR(255); - - -- Borrar cuando se cambie el insert ticket en la APP móvil - - SELECT typeFk INTO vClientType - FROM vn.`client` WHERE id = NEW.Id_Cliente; - - IF vClientType = 'loses' THEN - SET vStateCode = 'DELIVERED'; - ELSE - SET vStateCode = 'FREE'; - END IF; - - INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador) - SELECT NEW.Id_Ticket, id, vn.myWorker_getId() - FROM state - WHERE `code` = vStateCode 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 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 `ticket_beforeUpdate` - BEFORE UPDATE ON `Tickets` - FOR EACH ROW -BEGIN - IF !(NEW.Fecha <=> OLD.Fecha) THEN - IF YEAR(NEW.Fecha) < 2000 THEN - SIGNAL SQLSTATE '46000' - SET MESSAGE_TEXT = 'Year cannot be lesser than 2000'; - END IF; - - IF YEAR(NEW.Fecha) = 2000 THEN - SET NEW.isDeleted = TRUE; - END IF; - END IF; - - IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN - SET NEW.Fecha = DATE_FORMAT(NEW.Fecha, '2000-%m-%d %T'); - SET NEW.landing = DATE_FORMAT(NEW.landing, '2000-%m-%d %T'); - SET NEW.Id_Ruta = NULL; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!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 `ticket_afterUpdate` - AFTER UPDATE ON `Tickets` - FOR EACH ROW -BEGIN - IF !(NEW.Id_Ticket <=> OLD.Id_Ticket) - OR !(NEW.warehouse_id <=> OLD.warehouse_id) - OR !(NEW.Fecha <=> OLD.Fecha) THEN - CALL stock.log_add('ticket', NEW.Id_Ticket, OLD.Id_Ticket); - END IF; - - IF !(NEW.isDeleted <=> OLD.isDeleted) AND NEW.isDeleted THEN - INSERT INTO vncontrol.inter(Id_Ticket, state_id, Id_Trabajador) - SELECT NEW.Id_Ticket, id, vn.myWorker_getId() - FROM state - WHERE `code` = 'ERASED'; - 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 = 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 `ticket_beforeDelete` - BEFORE DELETE ON `Tickets` - FOR EACH ROW -BEGIN - DELETE FROM vn.sale WHERE ticketFk = OLD.Id_Ticket; - - DELETE FROM tickets_gestdoc WHERE Id_Ticket = OLD.Id_Ticket; -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 `Tickets`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Tickets` AS SELECT + 1 AS `Id_Ticket`, + 1 AS `Id_Cliente`, + 1 AS `warehouse_id`, + 1 AS `Fecha`, + 1 AS `landing`, + 1 AS `Alias`, + 1 AS `Factura`, + 1 AS `Id_Consigna`, + 1 AS `Localizacion`, + 1 AS `Solucion`, + 1 AS `Id_Ruta`, + 1 AS `empresa_id`, + 1 AS `Id_Agencia`, + 1 AS `Prioridad`, + 1 AS `Bultos`, + 1 AS `isDeleted`, + 1 AS `odbc_date`, + 1 AS `Notas`, + 1 AS `factura_id`, + 1 AS `Anotadoencaja`, + 1 AS `Id_Trabajador`, + 1 AS `Observaciones`, + 1 AS `Firmado`, + 1 AS `Etiquetasemitidas`, + 1 AS `PedidoImpreso`, + 1 AS `Hora`, + 1 AS `blocked`, + 1 AS `priority`, + 1 AS `boxed`, + 1 AS `zoneFk`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Tickets_dits` @@ -53314,10 +56514,10 @@ CREATE TABLE `Tickets_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), - CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64983115 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65096090 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 */ ; @@ -53381,43 +56581,40 @@ CREATE TABLE `Tickets_state` ( `state_name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`Id_Ticket`), KEY `double_foreign` (`Id_Ticket`,`inter_id`), - CONSTRAINT `Id_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Id_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `double_foreign` FOREIGN KEY (`Id_Ticket`, `inter_id`) REFERENCES `vncontrol`.`inter` (`Id_Ticket`, `inter_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 `Tickets_turno` +-- Temporary table structure for view `Tickets_turno` -- DROP TABLE IF EXISTS `Tickets_turno`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tickets_turno` ( - `Id_Ticket` int(11) NOT NULL AUTO_INCREMENT, - `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=2384112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Tickets_turno`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Tickets_turno` AS SELECT + 1 AS `Id_Ticket`, + 1 AS `weekDay`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Tintas` +-- Temporary table structure for view `Tintas` -- DROP TABLE IF EXISTS `Tintas`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tintas` ( - `Id_Tinta` char(3) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Tinta` blob NOT NULL, - `Orden` int(11) NOT NULL, - `ball` blob, - `cargex` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY (`Id_Tinta`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Tintas`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Tintas` AS SELECT + 1 AS `Id_Tinta`, + 1 AS `name`, + 1 AS `Tinta`, + 1 AS `Orden`, + 1 AS `ball`, + 1 AS `cargex`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `Tipos` @@ -53514,9 +56711,9 @@ CREATE TABLE `Trabajadores` ( KEY `sub` (`sub`), KEY `boss_idx` (`boss`), KEY `empresa_id` (`empresa_id`), - CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, + CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1368 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1448 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 */ ; @@ -53623,9 +56820,9 @@ CREATE TABLE `Vehiculos` ( PRIMARY KEY (`Id_Vehiculo`), KEY `empresa_id` (`empresa_id`), 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=429 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `Vehiculos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `vn`.`province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=435 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53656,8 +56853,8 @@ CREATE TABLE `Vehiculos_consumo` ( KEY `proveedoresFk_idx` (`proveedoresFk`), 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=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'; + CONSTRAINT `proveedoresFk` FOREIGN KEY (`proveedoresFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=12530 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 */; -- @@ -53678,20 +56875,18 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `Vistas` +-- Temporary table structure for view `Vistas` -- DROP TABLE IF EXISTS `Vistas`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Vistas` ( - `vista_id` int(11) NOT NULL AUTO_INCREMENT, - `vista` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`vista_id`), - UNIQUE KEY `code` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Vistas`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Vistas` AS SELECT + 1 AS `vista_id`, + 1 AS `code`, + 1 AS `vista`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `XDiario` @@ -53770,8 +56965,8 @@ CREATE TABLE `XDiario` ( `FECREGCON` date DEFAULT NULL, 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=3956747 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4001214 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 */ ; @@ -53856,8 +57051,8 @@ CREATE TABLE `account_conciliacion` ( UNIQUE KEY `idaccount_conciliacion_UNIQUE` (`idaccount_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=33264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `vn`.`supplierAccount` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=35179 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 */ ; @@ -53902,7 +57097,7 @@ CREATE TABLE `account_detail` ( KEY `fk_account_detail_account_detail_type1_idx` (`account_detail_type_id`), 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 + CONSTRAINT `fk_account_detail_account_id_proveedores_account` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `vn`.`supplierAccount` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -53957,52 +57152,24 @@ CREATE TABLE `agencia_descuadre` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `agency` +-- Temporary table structure for view `agency` -- DROP TABLE IF EXISTS `agency`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agency` ( - `agency_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `warehouse_id` smallint(5) unsigned DEFAULT NULL COMMENT 'A nulo si se puede enrutar desde todos los almacenes', - `por_volumen` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Si el calculo del porte se hacer por volumen', - `Id_Banco` int(11) NOT NULL DEFAULT '8' COMMENT 'para realizar los reembolsos', - `warehouse_alias_id` smallint(5) unsigned DEFAULT NULL, - `propios` tinyint(1) NOT NULL DEFAULT '0', - `zone_label` tinyint(4) NOT NULL DEFAULT '0', - `workCenterFk` int(11) DEFAULT NULL, - PRIMARY KEY (`agency_id`), - KEY `warehouse_id` (`warehouse_id`), - KEY `Id_Banco` (`Id_Banco`), - KEY `agencias_alias_idx` (`warehouse_alias_id`), - KEY `agency_ibfk_3_idx` (`workCenterFk`), - CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, - CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `vn`.`workCenter` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=282 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 `vn2008`.`agency_ai` -AFTER INSERT ON `vn2008`.`agency` -FOR EACH ROW -BEGIN - INSERT INTO Agencias(Agencia,agency_id) VALUES(NEW.name,NEW.agency_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 `agency`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agency` AS SELECT + 1 AS `agency_id`, + 1 AS `name`, + 1 AS `warehouse_id`, + 1 AS `por_volumen`, + 1 AS `Id_Banco`, + 1 AS `warehouse_alias_id`, + 1 AS `propios`, + 1 AS `zone_label`, + 1 AS `workCenterFk`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `agency_hour` @@ -54024,9 +57191,9 @@ CREATE TABLE `agency_hour` ( KEY `agency_id` (`agency_id`), KEY `warehouse_id` (`warehouse_id`), KEY `province_id` (`province_id`), - CONSTRAINT `agency_hour_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `agency` (`agency_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `agency_hour_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_hour_ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_hour_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `agency_hour_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5666 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -54102,7 +57269,7 @@ CREATE TABLE `agency_warehouse` ( `Vista` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`agency_id`,`warehouse_id`), KEY `warehouse_id` (`warehouse_id`), - CONSTRAINT `agency_warehouse_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `agency` (`agency_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `agency_warehouse_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_warehouse_ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Indica la vista para cada agencia'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -54185,15 +57352,15 @@ CREATE TABLE `albaran` ( KEY `fk_albaran_Trabajadores2_idx` (`Id_Responsable`), KEY `fk_albaran_department1_idx` (`department_id`), KEY `fk_albaran_recibida_idx` (`recibida_id`), - CONSTRAINT `fk_albaran_Proveedores` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, + CONSTRAINT `fk_albaran_Proveedores` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores2` FOREIGN KEY (`Id_Responsable`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_albaran_state1` FOREIGN KEY (`albaran_state_id`) REFERENCES `albaran_state` (`albaran_state_id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_department1` FOREIGN KEY (`department_id`) REFERENCES `department` (`department_id`) ON UPDATE CASCADE, - CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, + CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3514 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3601 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54270,9 +57437,9 @@ CREATE TABLE `awb` ( KEY `flight_id` (`flight_id`), KEY `awbInvoiceIn` (`invoiceInFk`), 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=3453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE, + CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3515 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 */ ; @@ -54438,7 +57605,7 @@ CREATE TABLE `awb_component` ( CONSTRAINT `awb_component_` FOREIGN KEY (`awb_component_type_id`) REFERENCES `awb_component_type` (`awb_component_type_id`) ON UPDATE CASCADE, CONSTRAINT `awb_role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=29183 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=30582 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54472,7 +57639,7 @@ CREATE TABLE `awb_component_template` ( 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=838 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=849 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54533,7 +57700,7 @@ CREATE TABLE `awb_daes` ( `supplierFk` int(11) DEFAULT NULL, PRIMARY KEY (`numdae`), KEY `awb_daes_fk1_idx` (`supplierFk`), - CONSTRAINT `awb_daes_fk1` FOREIGN KEY (`supplierFk`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE + CONSTRAINT `awb_daes_fk1` FOREIGN KEY (`supplierFk`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -54553,7 +57720,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=3041 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3098 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54657,37 +57824,31 @@ CREATE TABLE `balance_nest_tree` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `barcodes` +-- Temporary table structure for view `barcodes` -- DROP TABLE IF EXISTS `barcodes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `barcodes` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Article` int(11) NOT NULL, - `code` varchar(22) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `code` (`code`), - 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=41665 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `barcodes`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `barcodes` AS SELECT + 1 AS `id`, + 1 AS `Id_Article`, + 1 AS `code`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `bionic_updating_options` +-- Temporary table structure for view `bionic_updating_options` -- DROP TABLE IF EXISTS `bionic_updating_options`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `bionic_updating_options` ( - `buo_id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`buo_id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `bionic_updating_options`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `bionic_updating_options` AS SELECT + 1 AS `buo_id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `botanic_export` @@ -54706,7 +57867,7 @@ CREATE TABLE `botanic_export` ( `isProtectedZone` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`botanic_export_id`), KEY `Id_Paises` (`Id_Paises`), - CONSTRAINT `botanic_export_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `Paises` (`Id`) + CONSTRAINT `botanic_export_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `vn`.`country` (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=340 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Especifica los generos y especies prohibidos en paises'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -54731,18 +57892,17 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `businessReasonEnd` +-- Temporary table structure for view `businessReasonEnd` -- DROP TABLE IF EXISTS `businessReasonEnd`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `businessReasonEnd` ( - `id` tinyint(3) NOT NULL AUTO_INCREMENT, - `reason` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `businessReasonEnd`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `businessReasonEnd` AS SELECT + 1 AS `id`, + 1 AS `reason`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `business_labour_payrroll` @@ -54955,7 +58115,7 @@ CREATE TABLE `citykk` ( UNIQUE KEY `province_city_pk` (`province_id`,`name`), KEY `NST_CITY_FK_idx` (`nst_geo_id`), CONSTRAINT `nst_geo_city` FOREIGN KEY (`nst_geo_id`) REFERENCES `nst`.`geo` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `province_city_fk` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `province_city_fk` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=4423 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -55219,43 +58379,33 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `client_observation` +-- Temporary table structure for view `client_observation` -- DROP TABLE IF EXISTS `client_observation`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `client_observation` ( - `client_observation_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `text` text COLLATE utf8_unicode_ci NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`client_observation_id`), - KEY `Id_Trabajador` (`Id_Trabajador`), - 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=76825 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `client_observation`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `client_observation` AS SELECT + 1 AS `client_observation_id`, + 1 AS `Id_Cliente`, + 1 AS `Id_Trabajador`, + 1 AS `text`, + 1 AS `odbc_date`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `clientes_gestdoc` +-- Temporary table structure for view `clientes_gestdoc` -- DROP TABLE IF EXISTS `clientes_gestdoc`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientes_gestdoc` ( - `Id_Cliente` int(11) NOT NULL, - `gest_doc_id` int(11) NOT NULL, - PRIMARY KEY (`gest_doc_id`), - KEY `gest_doc_id` (`gest_doc_id`), - KEY `fk_clientes_gestdoc_1_idx` (`Id_Cliente`), - CONSTRAINT `clientes_gestdoc_ibfk_2` FOREIGN KEY (`gest_doc_id`) REFERENCES `gestdoc` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `fk_clientes_gestdoc_3` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `clientes_gestdoc`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientes_gestdoc` AS SELECT + 1 AS `Id_Cliente`, + 1 AS `gest_doc_id`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `clientes_regalos_enc` @@ -55294,21 +58444,19 @@ CREATE TABLE `clientes_regalos_lista_enc` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `clientes_tipo` +-- Temporary table structure for view `clientes_tipo` -- DROP TABLE IF EXISTS `clientes_tipo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `clientes_tipo` ( - `clientes_tipo_id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(20) CHARACTER SET utf8 NOT NULL, - `tipo` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `isCreatedAsServed` tinyint(1) DEFAULT '0', - PRIMARY KEY (`clientes_tipo_id`), - UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Establece categorias para poder agrupar las ventas'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `clientes_tipo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `clientes_tipo` AS SELECT + 1 AS `clientes_tipo_id`, + 1 AS `code`, + 1 AS `tipo`, + 1 AS `isCreatedAsServed`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `commission` @@ -55366,9 +58514,9 @@ CREATE TABLE `config_host` ( 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_1` FOREIGN KEY (`caja`) REFERENCES `vn`.`bank` (`id`) 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_3` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`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_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'; @@ -55503,7 +58651,7 @@ CREATE TABLE `credit_card` ( `obs` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`credit_card_id`), KEY `Id_Cliente` (`Id_Cliente`), - CONSTRAINT `credit_card_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `credit_card_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=956 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -55521,7 +58669,7 @@ CREATE TABLE `cyc` ( `cyc_id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`cyc_id`), KEY `Cliente` (`Id_Cliente`), - CONSTRAINT `Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE + CONSTRAINT `Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=467096 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que estan clasificados en Credito y Cau'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -55538,7 +58686,7 @@ CREATE TABLE `cyc_declaration` ( `Fecha` date NOT NULL, `Vencimiento` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`factura_id`), - CONSTRAINT `Factura` FOREIGN KEY (`factura_id`) REFERENCES `Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Factura` FOREIGN KEY (`factura_id`) REFERENCES `vn`.`invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Registro de las facturas declaradas a cyc'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -55591,39 +58739,35 @@ CREATE TABLE `department` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `device` +-- Temporary table structure for view `device` -- DROP TABLE IF EXISTS `device`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -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=330 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `device`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `device` AS SELECT + 1 AS `device_id`, + 1 AS `sn`, + 1 AS `macWifi`, + 1 AS `serialNumber`, + 1 AS `departmentFk`, + 1 AS `model`, + 1 AS `isOutOfService`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `device_user` +-- Temporary table structure for view `device_user` -- DROP TABLE IF EXISTS `device_user`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `device_user` ( - `device_id` int(11) NOT NULL, - `user_id` int(11) NOT NULL, - PRIMARY KEY (`device_id`,`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `device_user`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `device_user` AS SELECT + 1 AS `device_id`, + 1 AS `user_id`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `dhlKk` @@ -55888,45 +59032,36 @@ CREATE TABLE `emp_day_pay` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `empresa` +-- Temporary table structure for view `empresa` -- DROP TABLE IF EXISTS `empresa`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `empresa` ( - `id` smallint(5) unsigned NOT NULL, - `abbreviation` char(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `registro` varchar(120) COLLATE utf8_unicode_ci NOT NULL, - `gerente_id` int(11) NOT NULL, - `alta` date NOT NULL, - `baja` date DEFAULT NULL, - `logo` longblob, - `oficial` tinyint(1) unsigned NOT NULL DEFAULT '1', - `cyc` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0', - `rgb` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `mail` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `cuno` blob, - `ODBC_DATE` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, - `Id_Cliente` int(11) DEFAULT NULL, - `digito_factura` int(2) DEFAULT NULL, - `Id_Proveedores_account` mediumint(8) unsigned DEFAULT NULL, - `morosidad` tinyint(4) NOT NULL DEFAULT '0', - `empresa_grupo` int(11) NOT NULL DEFAULT '1' COMMENT 'usado para calcular los greuges ', - `CodigoEmpresa` int(2) DEFAULT NULL COMMENT 'Campo para movConta', - `footnotes` longtext COLLATE utf8_unicode_ci COMMENT 'pie de paginas en las facturas', - `phytosanitary` longtext COLLATE utf8_unicode_ci, - PRIMARY KEY (`id`), - KEY `gerente_id` (`gerente_id`), - KEY `empresa_cliente_idx` (`Id_Cliente`), - KEY `Id_Proveedores_account` (`Id_Proveedores_account`), - KEY `empresa_grupo_fk_idx` (`empresa_grupo`), - CONSTRAINT `empresa_cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `empresa_fk4` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `empresa_ibfk_1` FOREIGN KEY (`gerente_id`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `fk_empresa_grupo` FOREIGN KEY (`empresa_grupo`) REFERENCES `vn`.`companyGroup` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `empresa`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `empresa` AS SELECT + 1 AS `id`, + 1 AS `abbreviation`, + 1 AS `Id_Proveedores_account`, + 1 AS `gerente_id`, + 1 AS `digito_factura`, + 1 AS `footnotes`, + 1 AS `phytosanitary`, + 1 AS `CodigoEmpresa`, + 1 AS `empresa_grupo`, + 1 AS `morosidad`, + 1 AS `baja`, + 1 AS `registro`, + 1 AS `alta`, + 1 AS `logo`, + 1 AS `oficial`, + 1 AS `cyc`, + 1 AS `rgb`, + 1 AS `mail`, + 1 AS `cuno`, + 1 AS `ODBC_DATE`, + 1 AS `Id_Cliente`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `empresa_grupo` @@ -55974,145 +59109,46 @@ CREATE TABLE `escritos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `escritos_det` +-- Temporary table structure for view `escritos_det` -- DROP TABLE IF EXISTS `escritos_det`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `escritos_det` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(10) unsigned NOT NULL, - `escritos_id` int(10) unsigned NOT NULL, - `fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `Id_Trabajador` int(10) unsigned NOT NULL, - `Saldo` float NOT NULL, - `empresa_id` smallint(5) unsigned DEFAULT NULL, - `escritos_detcol` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `userFk` int(11) DEFAULT NULL, - 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=18012 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `escritos_det`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `escritos_det` AS SELECT + 1 AS `id`, + 1 AS `Id_Cliente`, + 1 AS `escritos_id`, + 1 AS `fecha`, + 1 AS `Id_Trabajador`, + 1 AS `userFk`, + 1 AS `empresa_id`, + 1 AS `saldo`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `expeditions` +-- Temporary table structure for view `expeditions` -- DROP TABLE IF EXISTS `expeditions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditions` ( - `expeditions_id` int(11) NOT NULL AUTO_INCREMENT, - `agency_id` int(11) NOT NULL, - `ticket_id` int(10) NOT NULL, - `EsBulto` int(11) DEFAULT '1', - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `reembolso` bit(1) DEFAULT b'0', - `recogida` bit(1) DEFAULT b'0', - `Id_Article` int(11) DEFAULT NULL, - `counter` smallint(5) unsigned NOT NULL, - `checked` tinyint(4) NOT NULL DEFAULT '0', - `workerFk` int(11) DEFAULT NULL, - `externalId` bigint(25) DEFAULT NULL, - PRIMARY KEY (`expeditions_id`), - KEY `index1` (`agency_id`), - KEY `index2` (`EsBulto`), - KEY `index3` (`odbc_date`), - 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=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 */ ; -/*!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`.`expeditionsBeforeInsert` -BEFORE INSERT ON `expeditions` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one -BEGIN - DECLARE intcounter INT; - DECLARE vShipFk INT; - - IF NEW.EsBulto > 0 THEN - - UPDATE Tickets SET Bultos = nz(Bultos) + 1 WHERE Id_Ticket = NEW.ticket_id; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter FROM expeditions e - INNER JOIN Tickets t1 ON e.ticket_id = t1.Id_Ticket - LEFT JOIN vn.ticketState ts ON ts.ticket = t1.Id_Ticket - INNER JOIN Tickets t2 ON t2.Id_Consigna = t1.Id_Consigna AND DATE(t2.Fecha) = DATE(t1.Fecha) AND t1.warehouse_id = t2.warehouse_id - WHERE t2.Id_Ticket = NEW.ticket_id AND ts.alertLevel < 3 AND t1.empresa_id = t2.empresa_id AND t1.Id_Agencia = t2.Id_Agencia; - SET NEW.`counter` = intcounter; - END IF; - - -- JGF 14/01/19 si existe un polizon queda anulado - SELECT shipFk INTO vShipFk FROM vn.stowaway WHERE id = NEW.ticket_id; - IF vShipFk THEN - CALL vn.stowawayUnBoarding(vShipFk, NEW.ticket_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 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`.`expeditionsBeforeUpdate` -BEFORE UPDATE ON `vn2008`.`expeditions` -FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one -BEGIN - IF NEW.counter <> OLD.counter THEN - IF (SELECT COUNT(*) FROM expeditions e - INNER JOIN Tickets t1 ON e.ticket_id = t1.Id_Ticket - INNER JOIN Tickets t2 ON t2.Id_Consigna = t1.Id_Consigna AND DATE(t2.Fecha) = DATE(t1.Fecha) - WHERE t1.Id_Ticket = NEW.ticket_id AND counter = NEW.counter) > 0 THEN - SET NEW.expeditions_id = NULL; - END IF; - 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 = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`expeditionsBeforeDelete` -BEFORE DELETE ON `expeditions` FOR EACH ROW -BEGIN - UPDATE Tickets SET Bultos = (SELECT COUNT(counter)-1 - FROM expeditions WHERE ticket_id = OLD.ticket_id and EsBulto) - WHERE Id_Ticket = OLD.ticket_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 `expeditions`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `expeditions` AS SELECT + 1 AS `expeditions_id`, + 1 AS `agency_id`, + 1 AS `ticket_id`, + 1 AS `EsBulto`, + 1 AS `odbc_date`, + 1 AS `Id_Article`, + 1 AS `counter`, + 1 AS `checked`, + 1 AS `workerFk`, + 1 AS `externalId`, + 1 AS `reembolso`, + 1 AS `recogida`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `expeditions_deleted` @@ -56170,7 +59206,7 @@ CREATE TABLE `filtros` ( `sql` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `Estanteria` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=145 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56267,7 +59303,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=1320483 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1347466 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 */ ; @@ -56335,26 +59371,21 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `gesttip` +-- Temporary table structure for view `gesttip` -- DROP TABLE IF EXISTS `gesttip`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `gesttip` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `tipo` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `path` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `writeRoleFk` int(10) unsigned DEFAULT NULL, - `readRoleFk` int(10) unsigned DEFAULT NULL, - `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `readRoleFk` (`readRoleFk`), - KEY `writeRoleFk` (`writeRoleFk`), - CONSTRAINT `readRoleFk` FOREIGN KEY (`readRoleFk`) REFERENCES `account`.`role` (`id`), - CONSTRAINT `writeRoleFk` FOREIGN KEY (`writeRoleFk`) REFERENCES `account`.`role` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `gesttip`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `gesttip` AS SELECT + 1 AS `id`, + 1 AS `tipo`, + 1 AS `path`, + 1 AS `readRoleFk`, + 1 AS `writeRoleFk`, + 1 AS `code`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `guillen` @@ -56417,7 +59448,7 @@ CREATE TABLE `integra2_escala` ( `warehouse_id` smallint(6) unsigned NOT NULL, PRIMARY KEY (`province_id`,`warehouse_id`), KEY `warehouse_escala_idx` (`warehouse_id`), - CONSTRAINT `province_escala` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `province_escala` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_escala` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -56433,7 +59464,7 @@ CREATE TABLE `integra2_province` ( `province_id` smallint(6) unsigned NOT NULL, `franquicia` varchar(65) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`province_id`), - CONSTRAINT `integra2_province_id` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `integra2_province_id` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -56471,9 +59502,9 @@ CREATE TABLE `intrastat_data` ( PRIMARY KEY (`id`), KEY `intrastat_id` (`intrastat_id`), KEY `recibida` (`recibida_id`), - CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, + CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `vn`.`intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80181 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=82076 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56494,8 +59525,8 @@ CREATE TABLE `invoiceCorrection` ( KEY `invoiceCorrection_ibfk_1_idx` (`cplusRectificationTypeFk`), KEY `cplusInvoiceTyoeFk_idx` (`cplusInvoiceType477Fk`), KEY `invoiceCorrectionTypeFk_idx` (`invoiceCorrectionTypeFk`), - CONSTRAINT `corrected_fk` FOREIGN KEY (`correctedFk`) REFERENCES `Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `correcting_fk` FOREIGN KEY (`correctingFk`) REFERENCES `Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `corrected_fk` FOREIGN KEY (`correctedFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `correcting_fk` FOREIGN KEY (`correctingFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cplusInvoiceTyoeFk` FOREIGN KEY (`cplusInvoiceType477Fk`) REFERENCES `vn`.`cplusInvoiceType477` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceCorrectionType_Fk33` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `vn`.`invoiceCorrectionType` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceCorrection_ibfk_1` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType` (`id`) ON UPDATE CASCADE @@ -56550,7 +59581,8 @@ SET character_set_client = utf8; 1 AS `item_id`, 1 AS `amount`, 1 AS `received`, - 1 AS `isVirtualStock`*/; + 1 AS `isVirtualStock`, + 1 AS `entryFk`*/; SET character_set_client = @saved_cs_client; -- @@ -56566,7 +59598,8 @@ SET character_set_client = utf8; 1 AS `dat`, 1 AS `item_id`, 1 AS `amount`, - 1 AS `delivered`*/; + 1 AS `delivered`, + 1 AS `entryFk`*/; SET character_set_client = @saved_cs_client; -- @@ -56590,86 +59623,72 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `iva_codigo` +-- Temporary table structure for view `iva_codigo` -- DROP TABLE IF EXISTS `iva_codigo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `iva_codigo` ( - `id` tinyint(2) unsigned NOT NULL AUTO_INCREMENT, - `fecha` date NOT NULL, - `codigo` varchar(10) COLLATE utf8_unicode_ci NOT NULL, - `iva_tipo_id` tinyint(2) NOT NULL, - `iva` decimal(4,1) NOT NULL DEFAULT '0.0', - `recargo` decimal(4,1) NOT NULL DEFAULT '0.0', - `tipo` char(1) COLLATE utf8_unicode_ci NOT NULL, - `link` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'las que tienen el mismo valor se contabilizan emparejadas', - `isActive` tinyint(2) NOT NULL DEFAULT '1', - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `transactionCode` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `iva_tipo_id` (`iva_tipo_id`), - KEY `codigo` (`codigo`), - KEY `tipo_index` (`tipo`), - CONSTRAINT `iva_codigo_ibfk_1` FOREIGN KEY (`iva_tipo_id`) REFERENCES `iva_tipo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `iva_codigo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `iva_codigo` AS SELECT + 1 AS `id`, + 1 AS `fecha`, + 1 AS `codigo`, + 1 AS `iva_tipo_id`, + 1 AS `iva`, + 1 AS `recargo`, + 1 AS `tipo`, + 1 AS `link`, + 1 AS `isActive`, + 1 AS `updated`, + 1 AS `transactionCode`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `iva_group` +-- Temporary table structure for view `iva_group` -- DROP TABLE IF EXISTS `iva_group`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `iva_group` ( - `iva_group_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'R', - PRIMARY KEY (`iva_group_id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `iva_group`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `iva_group` AS SELECT + 1 AS `iva_group_id`, + 1 AS `description`, + 1 AS `code`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `iva_group_codigo` +-- Temporary table structure for view `iva_group_codigo` -- DROP TABLE IF EXISTS `iva_group_codigo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `iva_group_codigo` ( - `iva_group_id` tinyint(3) unsigned NOT NULL, - `date` date NOT NULL, - `iva_codigo_id` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`iva_group_id`,`date`,`iva_codigo_id`), - KEY `iva_codigo_id` (`iva_codigo_id`), - CONSTRAINT `iva_group_codigo_ibfk_1` FOREIGN KEY (`iva_group_id`) REFERENCES `iva_group` (`iva_group_id`) ON UPDATE CASCADE, - CONSTRAINT `iva_group_codigo_ibfk_2` FOREIGN KEY (`iva_codigo_id`) REFERENCES `iva_codigo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `iva_group_codigo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `iva_group_codigo` AS SELECT + 1 AS `iva_group_id`, + 1 AS `date`, + 1 AS `iva_codigo_id`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `iva_tipo` +-- Temporary table structure for view `iva_tipo` -- DROP TABLE IF EXISTS `iva_tipo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `iva_tipo` ( - `id` tinyint(2) NOT NULL AUTO_INCREMENT, - `alias` varchar(6) COLLATE utf8_unicode_ci NOT NULL, - `isAccrued` tinyint(4) NOT NULL DEFAULT '0', - `serie_id` char(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ', - `descripcion` varchar(100) COLLATE utf8_unicode_ci NOT NULL, - `Id_Pais` mediumint(8) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `serie_id` (`serie_id`), - KEY `Id_Pais` (`Id_Pais`), - CONSTRAINT `iva_tipo_ibfk_1` FOREIGN KEY (`Id_Pais`) REFERENCES `Paises` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `iva_tipo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `iva_tipo` AS SELECT + 1 AS `id`, + 1 AS `alias`, + 1 AS `isAccrued`, + 1 AS `serie_id`, + 1 AS `TIPOOPE`, + 1 AS `descripcion`, + 1 AS `Id_Pais`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `jerarquia` @@ -56743,7 +59762,7 @@ CREATE TABLE `log_articles` ( KEY `Id_Article_log` (`Id_Article`), KEY `Id_Ticket_log` (`Id_Ticket_old`), KEY `Id_Ticket_new_log` (`Id_Ticket_new`), - CONSTRAINT `Id_Article_log_Articles` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE NO ACTION ON UPDATE CASCADE + CONSTRAINT `Id_Article_log_Articles` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los movimientos de los articulos para intentar encontrar los procesos que generan negativos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -56770,7 +59789,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1848508 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1886467 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56849,7 +59868,7 @@ CREATE TABLE `movement_label` ( `label` mediumint(8) unsigned NOT NULL, `stem` mediumint(8) unsigned NOT NULL, PRIMARY KEY (`Id_movimiento`), - CONSTRAINT `movement_label_ibfk_1` FOREIGN KEY (`Id_movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `movement_label_ibfk_1` FOREIGN KEY (`Id_movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE 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 */ ; @@ -56921,19 +59940,17 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `order_Tickets` +-- Temporary table structure for view `order_Tickets` -- DROP TABLE IF EXISTS `order_Tickets`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `order_Tickets` ( - `order_id` int(10) unsigned NOT NULL, - `Id_Ticket` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`Id_Ticket`,`order_id`), - KEY `order_id` (`order_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `order_Tickets`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `order_Tickets` AS SELECT + 1 AS `order_id`, + 1 AS `Id_Ticket`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `order_component` @@ -56999,12 +60016,12 @@ CREATE TABLE `pago` ( KEY `pay_met` (`pay_met_id`), KEY `proveedor_pago` (`id_proveedor`), 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_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, + CONSTRAINT `pago_ibfk_2` FOREIGN KEY (`id_banco`) REFERENCES `vn`.`bank` (`id`) 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=51126 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=51816 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 */ ; @@ -57082,25 +60099,24 @@ CREATE TABLE `pago_sdc` ( KEY `empresa_sdc_idx` (`empresa_id`), KEY `financial_type_fk_idx` (`financialProductTypefk`), KEY `pago_sdc_entity_fk_idx` (`entity_id`), - CONSTRAINT `empresa_sdc` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, + CONSTRAINT `empresa_sdc` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`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 `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 */; -- --- Table structure for table `pay_dem` +-- Temporary table structure for view `pay_dem` -- DROP TABLE IF EXISTS `pay_dem`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `pay_dem` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `pay_dem` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `pay_dem`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `pay_dem` AS SELECT + 1 AS `id`, + 1 AS `pay_dem`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `pay_dem_det` @@ -57130,6 +60146,7 @@ CREATE TABLE `pay_met` ( `deudaviva` tinyint(3) unsigned zerofill NOT NULL DEFAULT '000', `graceDays` int(11) unsigned NOT NULL DEFAULT '0', `ibanRequired` tinyint(3) DEFAULT '0', + `isNotified` tinyint(3) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -57418,7 +60435,7 @@ CREATE TABLE `plantpassport` ( KEY `plantpassport_authority_idx` (`plantpassport_authority_id`), KEY `producer_id_idx` (`producer_id`), CONSTRAINT `plantpassport_authority` FOREIGN KEY (`plantpassport_authority_id`) REFERENCES `plantpassport_authority` (`plantpassport_authority_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `producer` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`) ON UPDATE CASCADE + CONSTRAINT `producer` FOREIGN KEY (`producer_id`) REFERENCES `vn`.`producer` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='tiene la asignacion de cada productor con la autoridad certificadora'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -57436,7 +60453,7 @@ CREATE TABLE `plantpassport_authority` ( PRIMARY KEY (`plantpassport_authority_id`), UNIQUE KEY `denomination_UNIQUE` (`denomination`), KEY `Pais_id_idx` (`Paises_Id`), - CONSTRAINT `Pais_id` FOREIGN KEY (`Paises_Id`) REFERENCES `Paises` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Pais_id` FOREIGN KEY (`Paises_Id`) REFERENCES `vn`.`country` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='entidades certificadoras'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -57500,8 +60517,8 @@ CREATE TABLE `price_fixed` ( KEY `date_start` (`date_start`), 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=64019 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=64485 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 */ ; @@ -57551,20 +60568,18 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `producer` +-- Temporary table structure for view `producer` -- DROP TABLE IF EXISTS `producer`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `producer` ( - `producer_id` mediumint(3) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `visible` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`producer_id`), - UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=12600 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `producer`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `producer` AS SELECT + 1 AS `producer_id`, + 1 AS `name`, + 1 AS `visible`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `profile_labour_payroll` @@ -57602,133 +60617,23 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `province` +-- Temporary table structure for view `province` -- DROP TABLE IF EXISTS `province`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `province` ( - `province_id` smallint(6) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `Paises_Id` mediumint(8) unsigned NOT NULL, - `warehouse_id` smallint(6) unsigned DEFAULT NULL COMMENT 'warehouse responsable de las rutas', - `zone` tinyint(4) DEFAULT NULL, - `nst_geo_id` int(11) DEFAULT NULL, - `nst_name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `geoFk` int(11) DEFAULT NULL, - PRIMARY KEY (`province_id`), - KEY `Paises_Id` (`Paises_Id`), - KEY `warehouse_Id` (`warehouse_id`), - KEY `provicne_zone_fk_idx` (`zone`), - 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=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 = 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_beforeInsert` - BEFORE INSERT ON `province` FOR EACH ROW -BEGIN - 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 ; -/*!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_afterDelete` - AFTER DELETE ON `province` 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 */ ; +/*!50001 DROP VIEW IF EXISTS `province`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `province` AS SELECT + 1 AS `province_id`, + 1 AS `name`, + 1 AS `Paises_Id`, + 1 AS `warehouse_id`, + 1 AS `zone`, + 1 AS `geoFk`, + 1 AS `nst_geo_id`, + 1 AS `nst_name`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `rec_translator` @@ -57742,7 +60647,7 @@ CREATE TABLE `rec_translator` ( `denominacion` varchar(85) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`Id_Article`,`denominacion`), KEY `id_article_rec_idx` (`Id_Article`), - CONSTRAINT `id_article_rec` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `id_article_rec` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Equipara las denominaciones de las fincas de ecuador con nuestro Id_Article'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -57786,14 +60691,14 @@ CREATE TABLE `recibida` ( KEY `recibida_ibfk_5_idx` (`cplusInvoiceType472Fk`), KEY `recibida_ibfk_6` (`cplusRectificationTypeFk`), KEY `recibida_ibfk_7` (`cplusTrascendency472Fk`), - CONSTRAINT `recibida_ibfk_1` FOREIGN KEY (`proveedor_id`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, - CONSTRAINT `recibida_ibfk_2` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recibida_ibfk_1` FOREIGN KEY (`proveedor_id`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE, + CONSTRAINT `recibida_ibfk_2` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `vn`.`cplusSubjectOp` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `vn`.`cplusTaxBreak` (`id`) ON UPDATE CASCADE, 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=85928 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=87260 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 */ ; @@ -57812,7 +60717,6 @@ BEGIN DECLARE v_num_recibida INT; DECLARE pais_emisor, pais_receptor INT; DECLARE vActive TINYINT; - SELECT pais_id, active into pais_emisor, vActive FROM Proveedores WHERE Id_Proveedor = NEW.proveedor_id; SELECT pais_id into pais_receptor FROM Proveedores WHERE Id_Proveedor = NEW.empresa_id; @@ -57843,8 +60747,7 @@ BEGIN SET NEW.num_recibida = v_num_recibida; END IF; - - + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57864,10 +60767,6 @@ DELIMITER ;; -- Edit trigger body code below this line. Do not edit lines above this one BEGIN - DECLARE cta_proveed VARCHAR(10); - DECLARE cta_proveeda VARCHAR(10); - DECLARE v_num_recibida INT; - DECLARE dblRefRate,dblRefMin,dblRef DOUBLE; DECLARE vActive TINYINT; SELECT active INTO vActive FROM Proveedores WHERE Id_Proveedor = NEW.proveedor_id; @@ -57881,350 +60780,6 @@ BEGIN SET NEW.contabilizada = FALSE ; END IF; - - -/* PAK 27/11/17 ESto tiene pinta de no hacer falta.... - -IF NEW.contabilizada = 1 AND OLD.contabilizada = 0 AND NEW.fecha < '2017-07-01' THEN - - SELECT rate INTO dblRefRate FROM reference_rate WHERE date = (SELECT MAX(date) FROM reference_rate - WHERE date <= (SELECT t.shipment FROM - recibida_entrada re - INNER JOIN Entradas e ON e.Id_Entrada = re.Id_Entrada - LEFT JOIN travel t ON t.id = e.travel_id - WHERE re.awb_recibida = NEW.id GROUP BY re.awb_recibida)); - - SELECT rate INTO dblRefMin FROM reference_min WHERE date=(SELECT MAX(date) FROM reference_min - WHERE date<=(SELECT t.shipment FROM - recibida_entrada re - INNER JOIN Entradas e ON e.Id_Entrada = re.Id_Entrada - LEFT JOIN travel t ON t.id = e.travel_id - WHERE re.awb_recibida = NEW.id GROUP BY re.awb_recibida)); - - -- IF dblRefMin < dblRefRate THEN - -- SET dblRef = dblRefRate; - -- ELSE - -- SET dblRef =dblRefMin; - -- END IF; - SELECT IFNULL(MAX(r.num_recibida) + 1,1) INTO v_num_recibida FROM recibida r - WHERE r.serie LIKE NEW.serie - AND YEAR(r.fecha) = YEAR(NEW.fecha) - AND r.empresa_id = NEW.empresa_id GROUP BY r.empresa_id; - - SET NEW.num_recibida = IFNULL(v_num_recibida,1); - SELECT REPLACE(cuenta,' ','') INTO cta_proveed FROM Proveedores WHERE Id_Proveedor=NEW.proveedor_id; - - INSERT INTO XDiario(ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE, EUROHABER,BASEEURO, SERIE,FACTURA,IVA,DOCUMENTO, - L340,LRECT349,TIPOOPE,AUXILIAR,empresa_id,LDIFADUAN) -SELECT a,NEW.fecha,subcta,contra,concepto,eurodebe,eurohaber,baseeuro,serie,NEW.sref,iva, - (SELECT CONCAT(serie,'/', LPAD(v_num_recibida,5,'0'))),l340,LRECT349,TIPOOPE,AUXILIAR,NEW.empresa_id,LDIFADUAN - FROM - - (SELECT MAX(ASIEN) + 1 as a FROM XDiario) t - - INNER JOIN - - ( - - SELECT *,NEW.serie,0 LDIFADUAN FROM - - (SELECT CONCAT('s/fra',RIGHT(sref,8),':',LEFT(Proveedor, 10)) concepto FROM Proveedores - - INNER JOIN recibida ON Id_Proveedor = proveedor_id WHERE id = NEW.id) t4 - - INNER JOIN( - -- Linea del proveedor/acreedor - SELECT subcta,'' contra,eurodebe,ROUND(SUM(eurohaber) + 0.0001,2) eurohaber,baseeuro,0 iva, l340,LRECT349,TIPOOPE,'' AUXILIAR - - FROM ( - - SELECT cta_proveed subcta, - - NULL eurodebe, ROUND((1+(iva/100)*(r.serie = 'R'))*SUM(bi),2) eurohaber, NULL baseeuro,ri.recibida_id, 0 l340,0 LRECT349,' ' TIPOOPE - - FROM recibida r - - INNER JOIN recibida_iva ri ON ri.recibida_id = r.id INNER JOIN iva_codigo ic ON ri.iva_id = ic.id - - INNER JOIN Proveedores p ON p.Id_Proveedor=r.proveedor_id - INNER JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - WHERE r.id = NEW.id GROUP BY iva) t - - GROUP BY recibida_id - - UNION ALL - -- Linea de iva - SELECT ic.codigo,cta_proveed contra, - - ROUND(iva/100*SUM(ri.bi) + 0.0001,2) eurodebe, NULL eurohaber, - - ROUND(SUM(ri.bi),2) baseeuro,iva, 1 l340,(NOT ((p.pais_id <> p2.pais_id) AND pa.CEE < 2)) LRECT349,TIPOOPE, - IF(pa.CEE < 2 AND ri2.gastos_id IS NULL,'','*') AUXILIAR - FROM recibida r - - INNER JOIN recibida_iva ri ON ri.recibida_id = r.id - - LEFT JOIN recibida_iva ri2 ON ri2.recibida_id = r.id AND ri2.gastos_id LIKE '4751______' - - INNER JOIN iva_codigo ic ON ri.iva_id = ic.id - - INNER JOIN iva_tipo it ON it.id = ic.iva_tipo_id - - INNER JOIN Gastos g ON ri.gastos_id = g.Id_Gasto AND g.iva_tipo_id = ic.iva_tipo_id - - INNER JOIN Proveedores p ON p.Id_Proveedor=r.proveedor_id - - INNER JOIN Paises pa ON p.pais_id = pa.Id - - INNER JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - INNER JOIN Paises pa2 ON p2.pais_id = pa2.Id - WHERE r.id = NEW.id AND ic.tipo <> '-' AND link GROUP BY iva - -- JGF 2016-05-05 g.conbase - UNION ALL - -- Linea iva inversor sujeto pasivo - SELECT ic2.codigo,cta_proveed contra, - - NULL eurodebe, ROUND(ic2.iva/100*SUM(bi) + 0.0001,2) eurohaber, - - ROUND(SUM(bi),2) baseeuro,ic2.iva, 1 l340,0 LRECT349,TIPOOPE,'*' AUXILIAR - - FROM recibida r - - INNER JOIN recibida_iva ri ON ri.recibida_id = r.id - - INNER JOIN iva_codigo ic ON ri.iva_id = ic.id - - INNER JOIN iva_codigo ic2 ON ic2.link = ic.link AND ic.id <> ic2.id - - INNER JOIN iva_tipo it ON ic.iva_tipo_id = it.id - - WHERE r.id = NEW.id AND ic2.link GROUP BY ic2.iva - - UNION ALL - -- Linea de Gastos - SELECT if(gastos_id LIKE '4751______',LPAD(RIGHT(cta_proveed ,5),10,gastos_id),gastos_id),cta_proveed , - - if(gastos_id LIKE '4751______',NULL,ABS(ROUND(SUM(bi),2))) , - - if(gastos_id LIKE '4751______',ABS(ROUND(SUM(bi),2)),NULL) , - - NULL ,0, 0 l340,0 LRECT349,' ' TIPOOPE,'' AUXILIAR - - FROM recibida r - - INNER JOIN recibida_iva ri ON ri.recibida_id = r.id - - INNER JOIN Proveedores p ON p.Id_Proveedor=r.proveedor_id - - WHERE r.id = NEW.id AND gastos_id <> 5660000002 GROUP BY gastos_id - - UNION ALL - -- Iva Importacion pendiente - -- JGF 17/02/15 cambia la forma de declarar este tipo de importaciones, sólo afecta a transitarios - SELECT '4700000999',NULL,NULL ,ROUND(SUM(importe * (iva/100)),2),NULL ,0, 0 l340,0 LRECT349,' ' TIPOOPE,'' AUXILIAR - - FROM recibida r - JOIN recibida_intrastat ri ON r.id = ri.recibida_id - JOIN Intrastat i ON i.Codintrastat = ri.Codintrastat - JOIN iva_codigo ic ON ic.id = i.iva_codigo_id - WHERE ri.recibida_id = NEW.id GROUP BY ri.recibida_id - - ) t2 - - UNION ALL - - - -- Extracomunitarias gasto contra proveedor/acreedor - SELECT CONCAT('COMPRA s/fra ',sref,':',LEFT(p.Proveedor, 10)) concepto ,gastos_id,cuenta, - - ROUND(SUM(bi)/IF(r.serie='W' AND ri.divisa IS NULL,dblRefRate,1)* (re.percentage / 100),2),NULL ,IF( @a:=@a+1 ,NULL,NULL) ,0, 0 l340,0 LRECT349,' ' TIPOOPE,'' AUXILIAR,r.serie,0 LDIFADUAN - - FROM recibida_entrada re - - INNER JOIN recibida_iva ri ON re.recibida_id = ri.recibida_id - - INNER JOIN recibida r ON r.id = ri.recibida_id - - INNER JOIN Proveedores p ON p.Id_Proveedor = r.proveedor_id - - INNER JOIN Entradas e ON e.Id_Entrada = re.Id_Entrada - - LEFT JOIN travel t ON t.id = e.travel_id - - INNER JOIN (SELECT @a:=0,@cont:=1,@total:=0,@base:=2) t1 - - WHERE re.awb_recibida = NEW.id AND re.percentage GROUP BY r.id - -UNION ALL - - -- Extracomunitarias proveedor contra gasto - SELECT CONCAT('COMPRA s/fra ',sref,':',LEFT(p.Proveedor, 10)) concepto ,p.cuenta subcta,gastos_id, - - NULL eurodebe, ROUND((1+(iva/100)*(r.serie = 'R'))*SUM(bi)/IF(r.serie='W' AND ri.divisa IS NULL,dblRefRate,1)* (re.percentage / 100),2) eurohaber, - - NULL baseeuro,0 iva, 0 l340,0 LRECT349,' ' TIPOOPE,'' AUXILIAR,r.serie,0 LDIFADUAN - -- antes sols iva - FROM recibida_entrada re - - INNER JOIN recibida_iva ri ON re.recibida_id = ri.recibida_id - - INNER JOIN recibida r ON r.id = ri.recibida_id - - INNER JOIN iva_codigo ic ON ri.iva_id = ic.id - - INNER JOIN Proveedores p ON Id_Proveedor = r.proveedor_id - - INNER JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - WHERE re.awb_recibida = NEW.id AND re.percentage GROUP BY r.id - -UNION ALL - - -- Linea de iva adquisicion - SELECT CONCAT('ADQUI. INTRA FRA ',sref),ic.codigo,p.cuenta contra, - - ROUND(iva/100*SUM(ri.importe) + 0.0001,2) eurodebe, NULL eurohaber, - - ROUND(SUM(ri.importe),2) baseeuro,iva, 1 l340,1 LRECT349,TIPOOPE,'' AUXILIAR,r.serie,0 LDIFADUAN - - FROM awb_recibida ar - - JOIN awb a ON ar.awb_id = a.id - - JOIN iva_codigo ic ON a.iva_id = ic.id - - JOIN iva_tipo it ON ic.iva_tipo_id = it.id - - JOIN Proveedores p ON a.transitario_id = p.Id_Proveedor - - JOIN recibida_intrastat ri ON ri.recibida_id = ar.recibida_id - - JOIN recibida r ON r.id = ri.recibida_id - - JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - WHERE ar.recibida_id = NEW.id AND (p.pais_id <> p2.pais_id) - GROUP BY iva - - UNION ALL - - -- Linea de iva adquisicion - SELECT CONCAT('ADQUI. INTRA FRA ',sref),ic2.codigo,p.cuenta contra, - - NULL eurodebe, ROUND(ic2.iva/100*SUM(ri.importe) + 0.0001,2) eurohaber, - - ROUND(SUM(ri.importe),2) baseeuro,ic2.iva, 1 l340,0 LRECT349, TIPOOPE,'' AUXILIAR,r.serie,0 LDIFADUAN - - FROM awb_recibida ar - - JOIN awb a ON ar.awb_id = a.id - - JOIN iva_codigo ic ON a.iva_id = ic.id - - JOIN iva_codigo ic2 ON ic2.link = ic.link AND ic.id <> ic2.id - - JOIN iva_tipo it ON ic.iva_tipo_id = it.id - - JOIN Proveedores p ON a.transitario_id = p.Id_Proveedor - - JOIN recibida_intrastat ri ON ri.recibida_id = ar.recibida_id - - JOIN recibida r ON r.id = ar.recibida_id - - JOIN Proveedores p1 ON p1.Id_Proveedor = r.proveedor_id - - JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - WHERE ar.recibida_id = NEW.id AND (p.pais_id <> p2.pais_id) GROUP BY ic2.iva - - UNION ALL - -- Linea iva importacion - SELECT concepto,subcta,Cuenta, - IF (NOT ((ppais_id <> p2pais_id) AND CEE < 2), - - eurodebe - ,NULL)eurodebe,eurohaber,baseeuro, iva, - IF(@total:=@total+eurodebe ,0,0) l340, 0 LRECT349, - IF(@cont:=@cont+1,'','') TIPOOPE,'*' AUXILIAR,serie,1 LDIFADUAN FROM ( - - SELECT CONCAT('COMPRA FRA ',p.Proveedor) concepto,ic2.codigo subcta,p.Cuenta,ic2.iva, - ROUND(sum(costefijo * Cantidad / sub1.costetotal * sub2.importe)*(ic2.iva/100),2) eurodebe,NULL eurohaber, -- JGF 17/02/15 canvie 0.21 per ic.iva - ROUND(sum(costefijo * Cantidad / sub1.costetotal * sub2.importe),2) baseeuro,r.serie,pa.CEE,pa.Id_Paisreal ppais_id, - p2.pais_id p2pais_id,SUM(sub3.SumIntrastat *(ic2.iva/100)) SumIntrastat, p.Id_Proveedor,Codintrastat - - FROM awb_recibida ar - - JOIN recibida_entrada re ON ar.recibida_id = re.awb_recibida - - JOIN Compres c ON c.Id_Entrada = re.Id_Entrada - - INNER JOIN Articles a ON a.Id_Article = c.Id_Article - - INNER JOIN ( - - SELECT a.Codintrastat, sum(c.costefijo * c.Cantidad) as costetotal - - FROM Compres c - - JOIN Articles a ON a.Id_Article = c.Id_Article - - JOIN recibida_entrada re ON re.Id_Entrada = c.Id_Entrada - - JOIN awb_recibida ar ON ar.recibida_id = re.awb_recibida - - JOIN awb aw ON ar.awb_id = aw.id - - WHERE ar.recibida_id = NEW.id AND re.percentage - - GROUP BY a.Codintrastat - - ) sub1 USING(Codintrastat) - - INNER JOIN ( - - SELECT Codintrastat,ri.importe, i.iva_codigo_id - - FROM recibida_intrastat ri - JOIN Intrastat i USING(Codintrastat) - - WHERE ri.recibida_id = NEW.id - - ) sub2 USING(Codintrastat) - - INNER JOIN ( - - SELECT SUM(ri.importe) SumIntrastat - - FROM recibida_intrastat ri - - WHERE ri.recibida_id = NEW.id - - ) sub3 - - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - - JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor - - JOIN Paises pa ON p.pais_id = pa.Id - - JOIN recibida r ON r.id = re.recibida_id - - JOIN Proveedores p2 ON p2.Id_Proveedor = r.empresa_id - - JOIN iva_codigo ic2 ON ic2.id = sub2.iva_codigo_id -- JGF 15/04/15 nou canvi llei (Ali) - - WHERE re.awb_recibida = NEW.id AND re.percentage - -- canvie el cta_proveed like '___1______' per cero cuidao en les van de put - - GROUP BY p.Id_Proveedor, sub2.iva_codigo_id - -) t3 GROUP BY Id_Proveedor, iva)t4; - --- linea que estava a l'ultim WHERE -END IF; -*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58252,7 +60807,6 @@ BEGIN END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58356,7 +60910,7 @@ CREATE TABLE `recibida_intrastat` ( KEY `Codintrastat` (`Codintrastat`), KEY `recibida_id` (`recibida_id`), CONSTRAINT `recibida_intrastat_ibfk_1` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `recibida_intrastat_ibfk_2` FOREIGN KEY (`Codintrastat`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE + CONSTRAINT `recibida_intrastat_ibfk_2` FOREIGN KEY (`Codintrastat`) REFERENCES `vn`.`intrastat` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -58379,10 +60933,10 @@ CREATE TABLE `recibida_iva` ( KEY `gastos_id` (`gastos_id`), KEY `recibida_id` (`recibida_id`), KEY `recibida_iva_ibfk_2` (`iva_id`), - CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `Gastos` (`Id_Gasto`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=149814 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `vn`.`expence` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB AUTO_INCREMENT=156249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58403,9 +60957,9 @@ CREATE TABLE `recibida_vencimiento` ( PRIMARY KEY (`id`), KEY `recibida_id` (`recibida_id`), 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_6` FOREIGN KEY (`banco_id`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=147938 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=154384 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 */ ; @@ -58419,10 +60973,61 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`recibida_vencimiento_bi` BEFORE INSERT ON `vn2008`.`recibida_vencimiento` FOR EACH ROW -BEGIN/* - IF NEW.cantidad = 0 THEN - SET NEW.id = 5; - END IF;*/ +BEGIN + DECLARE vIsNotified BOOLEAN; + + SELECT isNotified INTO vIsNotified + FROM vn.invoiceIn ii + JOIN vn.supplier s ON s.id = ii.supplierFk + JOIN pay_met pm ON pm.id = s.payMethodFk + WHERE ii.id = NEW.recibida_id; + + IF (NEW.fecha <= CURDATE() AND vIsNotified) + THEN + INSERT INTO vn2008.mail SET + `to` = 'begonya@verdnatura.es', + `reply_to` = 'begonya@verdnatura.es', + `subject` = 'Añadido vencimiento en el pasado', + `text` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.cantidad,'€ en una fecha pasada en la recibida ', + NEW.recibida_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 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`.`recibida_vencimiento_BEFORE_UPDATE` +BEFORE UPDATE ON `recibida_vencimiento` FOR EACH ROW +BEGIN + DECLARE vIsNotified BOOLEAN; + + SELECT isNotified INTO vIsNotified + FROM vn.invoiceIn ii + JOIN vn.supplier s ON s.id = ii.supplierFk + JOIN pay_met pm ON pm.id = s.payMethodFk + WHERE ii.id = NEW.recibida_id; + + IF (NEW.fecha <= CURDATE() AND vIsNotified) + THEN + INSERT INTO vn2008.mail SET + `to` = 'begonya@verdnatura.es', + `reply_to` = 'begonya@verdnatura.es', + `subject` = 'Añadido vencimiento en el pasado', + `text` = CONCAT(account.myUserGetName(), ' ha añadido un vencimiento de ', + NEW.cantidad,'€ en una fecha pasada en la recibida ', + NEW.recibida_id); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58431,25 +61036,21 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `recovery` +-- Temporary table structure for view `recovery` -- DROP TABLE IF EXISTS `recovery`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `recovery` ( - `recovery_id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL DEFAULT '0', - `dstart` date NOT NULL COMMENT 'Fecha a partir de la que comienza el recobro', - `dend` date DEFAULT NULL COMMENT 'Fecha en la que acaba', - `amount` double NOT NULL, - `period` tinyint(3) unsigned NOT NULL DEFAULT '7' COMMENT 'numero de dias que indica cada cuanto hare el recobro', - PRIMARY KEY (`recovery_id`), - 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=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 */; +/*!50001 DROP VIEW IF EXISTS `recovery`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `recovery` AS SELECT + 1 AS `recovery_id`, + 1 AS `Id_Cliente`, + 1 AS `dstart`, + 1 AS `dend`, + 1 AS `amount`, + 1 AS `period`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `recovery_asset` @@ -58465,7 +61066,7 @@ CREATE TABLE `recovery_asset` ( `Id_Cliente` int(11) NOT NULL, PRIMARY KEY (`recovery_asset_id`), KEY `Cliente_Recovery_detalle_idx` (`Id_Cliente`), - CONSTRAINT `Cliente_Recovery_detalle` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE + CONSTRAINT `Cliente_Recovery_detalle` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=723 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla se registra el detalle de los recobros definid'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -58591,7 +61192,7 @@ CREATE TABLE `ruta_location` ( `latitude` decimal(11,7) NOT NULL, `time_location` datetime NOT NULL, PRIMARY KEY (`Id_Ruta`), - CONSTRAINT `Id_Ruta_Location` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `Id_Ruta_Location` FOREIGN KEY (`Id_Ruta`) REFERENCES `vn`.`route` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -58628,7 +61229,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=105074 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=108199 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 */; -- @@ -58670,150 +61271,41 @@ 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=1324937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1371651 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `sharingcart` +-- Temporary table structure for view `sharingcart` -- DROP TABLE IF EXISTS `sharingcart`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sharingcart` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Trabajador` int(11) NOT NULL, - `datSTART` date NOT NULL, - `datEND` date NOT NULL, - `Id_Suplente` int(11) NOT NULL, - `odbc_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `Worker` (`Id_Trabajador`), - 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=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 */ ; -/*!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 `sharingcart_bi` BEFORE INSERT ON `sharingcart` FOR EACH ROW - -BEGIN - - SET NEW.datSTART = GREATEST(CURDATE(),NEW.datSTART); - SET NEW.datEND = GREATEST(CURDATE(),NEW.datEND); - - IF NEW.Id_Trabajador = NEW.Id_Suplente THEN - SET NEW.Id_Trabajador = NULL; - - - -END IF; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!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 `sharingcart_bu` BEFORE UPDATE ON `sharingcart` FOR EACH ROW - -BEGIN - - SET NEW.datSTART = GREATEST(CURDATE(),NEW.datSTART); - SET NEW.datEND = GREATEST(CURDATE(),NEW.datEND); - - IF NEW.Id_Trabajador = NEW.Id_Suplente THEN - SET NEW.Id_Trabajador = NULL; - - -END IF; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `sharingcart`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `sharingcart` AS SELECT + 1 AS `id`, + 1 AS `Id_Trabajador`, + 1 AS `datSTART`, + 1 AS `datEND`, + 1 AS `Id_Suplente`, + 1 AS `odbc_date`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `sharingclient` +-- Temporary table structure for view `sharingclient` -- DROP TABLE IF EXISTS `sharingclient`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sharingclient` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Trabajador` int(11) NOT NULL, - `datSTART` date NOT NULL, - `datEND` date NOT NULL, - `Id_Cliente` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `Worker` (`Id_Trabajador`), - KEY `Client` (`Id_Cliente`), - CONSTRAINT `Clients_key` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, - CONSTRAINT `Trabajadores_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`sharingclient_BEFORE_INSERT` BEFORE INSERT ON `sharingclient` FOR EACH ROW -BEGIN - -SET NEW.datEND = GREATEST(CURDATE(),NEW.datEND); -SET NEW.datSTART = GREATEST(CURDATE(),NEW.datSTART); - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`sharingclient_BEFORE_UPDATE` BEFORE UPDATE ON `sharingclient` FOR EACH ROW -BEGIN - -SET NEW.datEND = GREATEST(CURDATE(),NEW.datEND); -SET NEW.datSTART = GREATEST(CURDATE(),NEW.datSTART); - -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 `sharingclient`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `sharingclient` AS SELECT + 1 AS `id`, + 1 AS `Id_Trabajador`, + 1 AS `datSTART`, + 1 AS `datEND`, + 1 AS `Id_Cliente`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `sms` @@ -58845,6 +61337,7 @@ DROP TABLE IF EXISTS `sort_merge_results_ernesto`; CREATE TABLE `sort_merge_results_ernesto` ( `hora` datetime NOT NULL, `uptime` int(11) DEFAULT NULL, + `log_output` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, `uptime_since_flush` int(11) DEFAULT NULL, `smp_old` int(11) DEFAULT NULL, `smp_new` int(11) DEFAULT NULL, @@ -58889,25 +61382,24 @@ CREATE TABLE `sort_merge_results_ernesto` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `state` +-- Temporary table structure for view `state` -- DROP TABLE IF EXISTS `state`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `state` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `order` tinyint(3) unsigned DEFAULT NULL, - `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=30 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `state`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `state` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `order`, + 1 AS `alert_level`, + 1 AS `code`, + 1 AS `sectorProdPriority`, + 1 AS `nextStateFk`, + 1 AS `isPreviousPreparable`, + 1 AS `isPicked`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `tag` @@ -58975,7 +61467,7 @@ CREATE TABLE `tarifas` ( PRIMARY KEY (`tarifa_id`), KEY `tarifa_warehouse` (`warehouse_id`), CONSTRAINT `tarifa_warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=186 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=193 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59169,29 +61661,24 @@ CREATE TABLE `ticket_location` ( `longitude` decimal(11,7) DEFAULT NULL, `latitude` decimal(11,7) DEFAULT NULL, PRIMARY KEY (`Id_Ticket`), - CONSTRAINT `Id_Ticket_Location` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Id_Ticket_Location` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`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 `ticket_observation` +-- Temporary table structure for view `ticket_observation` -- DROP TABLE IF EXISTS `ticket_observation`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ticket_observation` ( - `ticket_observation_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Ticket` int(11) NOT NULL, - `observation_type_id` tinyint(3) unsigned NOT NULL, - `text` text COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`ticket_observation_id`), - 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 `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 */; +/*!50001 DROP VIEW IF EXISTS `ticket_observation`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticket_observation` AS SELECT + 1 AS `ticket_observation_id`, + 1 AS `Id_Ticket`, + 1 AS `observation_type_id`, + 1 AS `text`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `tickets_gestdoc` @@ -59206,7 +61693,7 @@ CREATE TABLE `tickets_gestdoc` ( PRIMARY KEY (`Id_Ticket`,`gestdoc_id`), KEY `gestdoc_id` (`gestdoc_id`), CONSTRAINT `dmsFk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketFk` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON UPDATE CASCADE + CONSTRAINT `ticketFk` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) 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 */ ; @@ -59349,7 +61836,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=236008 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=240308 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59376,10 +61863,10 @@ CREATE TABLE `travel_pattern` ( KEY `agency_id` (`agency_id`), KEY `travel_pattern_ibfk_6_idx` (`cargoSupplierFk`), CONSTRAINT `travel_pattern_ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, + CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern_ibfk_6` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `Proveedores` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=344 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `travel_pattern_ibfk_6` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59544,7 +62031,7 @@ CREATE TABLE `unary_scan_line_buy` ( PRIMARY KEY (`scan_line_id`), UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), KEY `Id_Article_buy_idx` (`Id_Article`), - CONSTRAINT `Id_Article_buy` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `Id_Article_buy` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `scan_line_id_patriarcal` FOREIGN KEY (`scan_line_id`) REFERENCES `unary_scan_line` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -59562,7 +62049,7 @@ CREATE TABLE `unary_scan_line_expedition` ( PRIMARY KEY (`scan_line_id`), UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), KEY `expedition_id_scan_idx` (`expedition_id`), - CONSTRAINT `expedition_id_scan` FOREIGN KEY (`expedition_id`) REFERENCES `expeditions` (`expeditions_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `expedition_id_scan` FOREIGN KEY (`expedition_id`) REFERENCES `vn`.`expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -60411,10 +62898,11 @@ CREATE TABLE `warehouse` ( `valuatedInventory` tinyint(2) NOT NULL DEFAULT '0', `isManaged` tinyint(2) NOT NULL DEFAULT '0' COMMENT 'Se añaden los cubos de expedition a la tabla ticketPackaging', `hasConfectionTeam` tinyint(1) unsigned NOT NULL DEFAULT '0', + `hasStowaway` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`Id_Paises`), - CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `Paises` (`Id`) + CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `vn`.`country` (`Id`) ) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -60556,7 +63044,7 @@ CREATE TABLE `warehouse_pickup` ( PRIMARY KEY (`warehouse_id`), UNIQUE KEY `agency_id` (`agency_id`,`warehouse_id`), CONSTRAINT `warehouse_pickup_ibfk_1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_pickup_ibfk_2` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `warehouse_pickup_ibfk_2` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -60654,7 +63142,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=232 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=240 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -60699,21 +63187,6 @@ 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` -- @@ -61090,7 +63563,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 `bionicCalcReverse` */; +/*!50003 DROP FUNCTION IF EXISTS `bionicCalcReverseKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -61100,12 +63573,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse`(vWarehouse INT, +CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverseKk`(vWarehouse INT, vMargin DECIMAL(10,3), vRetailedPrice DECIMAL(10,3), vM3 DECIMAL(10,3), vConsigna INT, vAgencia INT) RETURNS decimal(10,3) + DETERMINISTIC BEGIN DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.3; DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; @@ -65319,302 +67793,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_component` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_component`(IN `v_consigna` INT, IN `v_agencia` INT) -proc: BEGIN - - DECLARE v_customer INT; - DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.0; - DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; - DECLARE VOLUMEN_CAJA_VERDNATURA BIGINT; -- DEFAULT 138000; - -- DECLARE vValorEmbolsado DOUBLE DEFAULT 0.04; - - CALL util.THROW('OBSOLETO'); - - SELECT Volumen INTO VOLUMEN_CAJA_VERDNATURA - FROM Cubos - WHERE Id_Cubo = '94'; - - SELECT Id_Cliente INTO v_customer FROM Consignatarios WHERE Id_Consigna = v_consigna; - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS t_bionic_temp; - CREATE TEMPORARY TABLE t_bionic_temp - (PRIMARY KEY (item_id,warehouse_id)) - ENGINE = MEMORY - SELECT - b.item_id, b.warehouse_id,available, - IF((@rate2 := IFNULL(pf.rate_2,c.Tarifa2)) < a.PVP AND a.`Min`, a.PVP, @rate2) * 1.0 rate_2, - IF((@rate3 := IFNULL(pf.rate_3,c.Tarifa3)) < a.PVP AND a.`Min`, a.PVP, @rate3) * 1.0 rate_3, - ifnull(pf.rate_3,0) AS min_price, - IFNULL(pf.Packing,c.Packing) packing, - IFNULL(pf.`grouping`,c.`grouping`) `grouping`, - ABS(IFNULL(pf.caja,c.caja)) box, - b.buy_id, a.tipo_id - FROM tmp.bionic_lot b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - JOIN vn2008.Articles a ON b.item_id = a.Id_Article - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = t.reino_id - LEFT JOIN vn2008.PreciosEspeciales p ON a.Id_Article = p.Id_Article AND p.Id_Cliente = v_customer - LEFT JOIN ( - SELECT * FROM ( - SELECT p.item_id, p.`grouping`, p.Packing, p.caja, p.rate_2, p.rate_3, zgs.warehouseFk AS warehouse_id - FROM vn2008.price_fixed p - JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = p.warehouse_id OR p.warehouse_id = 0 - WHERE zgs.shipped BETWEEN p.date_start AND p.date_end ORDER BY p.item_id, p.warehouse_id DESC - ) t - GROUP BY item_id, warehouse_id - ) pf ON pf.item_id = b.item_id AND pf.warehouse_id = b.warehouse_id - -- descartamos articulos con coste menor de 0.01 - WHERE Costefijo + Portefijo + Embalajefijo + Comisionfija > 0.01 AND r.display <> 0; - - -- Creamos la tabla tmp.bionic_component - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component; - CREATE TEMPORARY TABLE tmp.bionic_component LIKE - template_bionic_component; - - -- Componentes del precio, valores absolutos - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 29, rate_3 - Costefijo - Portefijo - Embalajefijo - Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 28, Costefijo + Portefijo + Embalajefijo + Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - -- Ahora los valores en funcion de la base - - DROP TEMPORARY TABLE IF EXISTS t_components_base; - - CREATE TEMPORARY TABLE t_components_base - SELECT bc.item_id, ROUND(SUM(cost), 4) AS base, bc.warehouse_id - FROM tmp.bionic_component bc - GROUP BY bc.item_id,warehouse_id; - - -- La ratio se calcula teniendo en cuenta el valor de las reclamaciones y el saldo de greuge - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 17, ROUND(base * LEAST(recobro,0.25), 3) - FROM t_components_base cb - JOIN bi.claims_ratio ON Id_Cliente = v_customer - WHERE recobro > 0.009; - - -- PAK 2016-08-31 Componente de maná automático, en función del maná acumulado por el comercial. - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 39, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM t_components_base cb - JOIN Clientes c on c.Id_Cliente = v_customer - JOIN bs.mana_spellers ms ON c.Id_Trabajador = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - AND c.Id_Trabajador != 196 -- Ruben Espinosa - HAVING manaAuto <> 0 ; - - -/* - -- Vendedor variable - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, Id_Componente, IFNULL(ROUND(base * tax,4), 0) - FROM t_components_base cb - JOIN bi.tarifa_componentes - WHERE tarifa_componentes_series_id = 2 and IFNULL(tax, 0) > 0; - */ - - --- ******* Inicio Bloque para componentes con tarifa_class diferente de NULL - -- Descuento por ultimas unidades - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, b.item_id, Id_Componente, GREATEST(IFNULL(ROUND(base * tax,4), 0), b.min_price - b.rate_3) - FROM t_components_base cb - JOIN bi.tarifa_componentes - JOIN t_bionic_temp b ON b.item_id = cb.item_id AND b.warehouse_id = cb.warehouse_id - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE Id_Componente = 32 AND tax <> 0 AND b.min_price < b.rate_3 AND PrecioEspecial IS NULL; - - -- Incremento por paquete suelto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 22, rate_2 - rate_3 - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE PrecioEspecial IS NULL; - --- ******* Fin Bloque para componentes con tarifa_class diferente de NULL - - -- Reparto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 15 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * IFNULL(az.price - * az.inflacion ,50) - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - HAVING cost <> 0; - --- Reparto bonificado - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 41 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - -- * awb.bonus - * az.inflacion - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - -- JOIN vn2008.agency_weekday_bonus awb ON awb.warehouse_id = az.warehouse_id AND awb.zona = az.zona AND a.agency_id = awb.agency_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = awb.warehouse_id AND weekday(ah.landed) = awb.weekDay - HAVING cost <> 0 - LIMIT 1; - --- PAK 12-05-2015 - -- EMBOLSADO - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = v_consigna) THEN - - -- IF v_consigna IN (13690, 3402, 5661, 4233) THEN - - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 38, ap.packagingValue cost - FROM t_bionic_temp b - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = v_consigna; - - END IF; - - -- JGF 14-08-2015 - -- Modificacion de precio por dia de preparacion del pedido - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, cb.item_id, 14, cb.base * (IFNULL(pe.percentage,pp.percentage)/100) - FROM t_components_base cb - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = cb.warehouse_id - LEFT JOIN vn2008.preparation_percentage pp ON pp.week_day = weekday(ah.shipped) AND cb.warehouse_id = IFNULL(pp.warehouse_id,cb.warehouse_id) - LEFT JOIN vn2008.preparation_exception pe ON pe.exception_day = ah.shipped AND cb.warehouse_id = IFNULL(pe.warehouse_id,cb.warehouse_id) - WHERE IFNULL(pe.percentage,pp.percentage); - - -- Creamos la tabla tmp.bionic_component_copy por que mysql no puede reabrir una tabla temporal - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component_copy; - CREATE TEMPORARY TABLE tmp.bionic_component_copy - SELECT * FROM tmp.bionic_component; - - -- JGF 19-01-2016 - -- Precios especiales - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 10, pe.PrecioEspecial - SUM(cost) sum_cost - FROM tmp.bionic_component_copy b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE t.tarifa_class IS NULL - GROUP BY b.item_id, b.warehouse_id - HAVING ABS(sum_cost) > 0.001; - - -- Lotes - DROP TEMPORARY TABLE IF EXISTS t_component_sum; - CREATE TEMPORARY TABLE t_component_sum - (INDEX (item_id, warehouse_id)) - ENGINE = MEMORY - SELECT SUM(cost) sum_cost, b.item_id, b.warehouse_id, t.tarifa_class - FROM tmp.bionic_component b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - GROUP BY b.item_id, b.warehouse_id, t.tarifa_class; - - -- ***** Inicia Modifica t_bionic_rate las diferentes tarifas - -- Tarifa por unidad minima - DROP TEMPORARY TABLE IF EXISTS t_bionic_rate; - CREATE TEMPORARY TABLE t_bionic_rate - ENGINE = MEMORY - SELECT b.warehouse_id, item_id, 1 rate, - IF(box = 1, `grouping`, 1) `grouping`, SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,1) = 1 AND box < 2 AND (packing > `grouping` or box = 0) - GROUP BY warehouse_id, item_id; - - -- Tarifa por caja - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 2 rate, packing `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE available IS NULL OR (IFNULL(cs.tarifa_class,2) = 2 AND packing > 0 AND available >= packing) - GROUP BY warehouse_id, item_id; - - -- Tarifa para toda la cantidad disponible - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 3 rate, available `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,3) = 3 - GROUP BY warehouse_id, item_id; - - -- ***** Fin Modifica t_bionic_rate las diferentes tarifas - - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_price; - CREATE TEMPORARY TABLE tmp.bionic_price - LIKE template_bionic_price; - - INSERT INTO tmp.bionic_price (warehouse_id, item_id, rate, `grouping`, price) - SELECT * FROM ( - SELECT * FROM t_bionic_rate ORDER BY price - ) t - GROUP BY item_id, warehouse_id, `grouping`; - - - DROP TEMPORARY TABLE IF EXISTS tmp.travel_tree; - CREATE TEMPORARY TABLE tmp.travel_tree - ENGINE = MEMORY - SELECT * FROM tmp.agencyHourGetShipped; - - -- Limpieza - - DROP TEMPORARY TABLE tmp.agencyHourGetShipped; - DROP TEMPORARY TABLE t_bionic_temp; - DROP TEMPORARY TABLE t_component_sum; - DROP TEMPORARY TABLE t_components_base; - DROP TEMPORARY TABLE t_bionic_rate; - DROP TEMPORARY TABLE tmp.bionic_component_copy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_componentTestKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65905,295 +68083,296 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_component_betaKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_component__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = 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 `bionic_calc_component_betaKk`(IN `v_consigna` INT, IN `v_agencia` INT) -proc: BEGIN - - DECLARE v_customer INT; - DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.3; - DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; - DECLARE VOLUMEN_CAJA_VERDNATURA BIGINT; - -- DECLARE vValorEmbolsado DOUBLE DEFAULT 0.04; - - - SELECT Volumen INTO VOLUMEN_CAJA_VERDNATURA - FROM Cubos - WHERE Id_Cubo = 94; - - SELECT Id_Cliente INTO v_customer FROM Consignatarios WHERE Id_Consigna = v_consigna; - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS t_bionic_temp; - CREATE TEMPORARY TABLE t_bionic_temp - (PRIMARY KEY (item_id,warehouse_id)) - ENGINE = MEMORY - SELECT - b.item_id, b.warehouse_id,available, - IF((@rate2 := IFNULL(pf.rate_2,c.Tarifa2)) < a.PVP AND a.`Min`, a.PVP, @rate2) * 1.0 rate_2, - IF((@rate3 := IFNULL(pf.rate_3,c.Tarifa3)) < a.PVP AND a.`Min`, a.PVP, @rate3) * 1.0 rate_3, - ifnull(pf.rate_3,0) AS min_price, - IFNULL(pf.Packing,c.Packing) packing, - IFNULL(pf.`grouping`,c.`grouping`) `grouping`, - ABS(IFNULL(pf.caja,c.caja)) box, - b.buy_id, a.tipo_id - FROM tmp.bionic_lot b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - JOIN vn2008.Articles a ON b.item_id = a.Id_Article - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = t.reino_id - LEFT JOIN vn2008.PreciosEspeciales p ON a.Id_Article = p.Id_Article AND p.Id_Cliente = v_customer - LEFT JOIN ( - SELECT * FROM ( - SELECT p.item_id, p.`grouping`, p.Packing,p.caja, p.rate_2, p.rate_3, ah.warehouseFk AS warehouse_id - FROM vn2008.price_fixed p - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = p.warehouse_id OR p.warehouse_id = 0 - WHERE ah.shipped BETWEEN p.date_start AND p.date_end ORDER BY p.item_id, p.warehouse_id DESC - ) t - GROUP BY item_id, warehouse_id - ) pf ON pf.item_id = b.item_id AND pf.warehouse_id = b.warehouse_id - -- descartamos articulos con coste menor de 0.01 - WHERE Costefijo + Portefijo + Embalajefijo + Comisionfija > 0.01 AND r.display <> 0; - - -- Creamos la tabla tmp.bionic_component - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component; - CREATE TEMPORARY TABLE tmp.bionic_component LIKE - template_bionic_component; - - -- Componentes del precio, valores absolutos - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 29, rate_3 - Costefijo - Portefijo - Embalajefijo - Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 28, Costefijo + Portefijo + Embalajefijo + Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - -- Ahora los valores en funcion de la base - - DROP TEMPORARY TABLE IF EXISTS t_components_base; - - CREATE TEMPORARY TABLE t_components_base - SELECT bc.item_id, ROUND(SUM(cost), 4) AS base, bc.warehouse_id - FROM tmp.bionic_component bc - GROUP BY bc.item_id,warehouse_id; - - -- La ratio se calcula teniendo en cuenta el valor de las reclamaciones y el saldo de greuge - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 17, ROUND(base * LEAST(recobro,0.25), 3) - FROM t_components_base cb - JOIN bi.claims_ratio ON Id_Cliente = v_customer - WHERE recobro > 0.009; - - -- PAK 2016-08-31 Componente de maná automático, en función del maná acumulado por el comercial. - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 39, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM t_components_base cb - JOIN Clientes c on c.Id_Cliente = v_customer - JOIN bs.mana_spellers ms ON c.Id_Trabajador = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - AND c.Id_Trabajador != 196 -- Ruben Espinosa - HAVING manaAuto <> 0 ; - - -/* - -- Vendedor variable - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, Id_Componente, IFNULL(ROUND(base * tax,4), 0) - FROM t_components_base cb - JOIN bi.tarifa_componentes - WHERE tarifa_componentes_series_id = 2 and IFNULL(tax, 0) > 0; - */ - - --- ******* Inicio Bloque para componentes con tarifa_class diferente de NULL - -- Descuento por ultimas unidades - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, b.item_id, Id_Componente, GREATEST(IFNULL(ROUND(base * tax,4), 0), b.min_price - b.rate_3) - FROM t_components_base cb - JOIN bi.tarifa_componentes - JOIN t_bionic_temp b ON b.item_id = cb.item_id AND b.warehouse_id = cb.warehouse_id - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE Id_Componente = 32 AND tax <> 0 AND b.min_price < b.rate_3 AND PrecioEspecial IS NULL; - - -- Incremento por paquete suelto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 22, rate_2 - rate_3 - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE PrecioEspecial IS NULL; - --- ******* Fin Bloque para componentes con tarifa_class diferente de NULL - - -- Reparto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 15 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * IFNULL(az.price - * az.inflacion ,50) - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - HAVING cost <> 0; - --- Reparto bonificado - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 41 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * awb.bonus - * az.inflacion - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - JOIN vn2008.agency_weekday_bonus awb ON awb.warehouse_id = az.warehouse_id AND awb.zona = az.zona AND a.agency_id = awb.agency_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = awb.warehouse_id AND weekday(ah.landed) = awb.weekDay - HAVING cost <> 0 - LIMIT 1; - --- PAK 12-05-2015 - -- EMBOLSADO - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = v_consigna) THEN - - -- IF v_consigna IN (13690, 3402, 5661, 4233) THEN - - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 38, ap.packagingValue cost - FROM t_bionic_temp b - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = v_consigna; - - END IF; - - -- JGF 14-08-2015 - -- Modificacion de precio por dia de preparacion del pedido - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, cb.item_id, 14, cb.base * (IFNULL(pe.percentage,pp.percentage)/100) - FROM t_components_base cb - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = cb.warehouse_id - LEFT JOIN vn2008.preparation_percentage pp ON pp.week_day = weekday(ah.shipped) AND cb.warehouse_id = IFNULL(pp.warehouse_id,cb.warehouse_id) - LEFT JOIN vn2008.preparation_exception pe ON pe.exception_day = ah.shipped AND cb.warehouse_id = IFNULL(pe.warehouse_id,cb.warehouse_id) - WHERE IFNULL(pe.percentage,pp.percentage); - - -- Creamos la tabla tmp.bionic_component_copy por que mysql no puede reabrir una tabla temporal - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component_copy; - CREATE TEMPORARY TABLE tmp.bionic_component_copy - SELECT * FROM tmp.bionic_component; - - -- JGF 19-01-2016 - -- Precios especiales - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 10, pe.PrecioEspecial - SUM(cost) sum_cost - FROM tmp.bionic_component_copy b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE t.tarifa_class IS NULL - GROUP BY b.item_id, b.warehouse_id - HAVING ABS(sum_cost) > 0.001; - - -- Lotes - DROP TEMPORARY TABLE IF EXISTS t_component_sum; - CREATE TEMPORARY TABLE t_component_sum - (INDEX (item_id, warehouse_id)) - ENGINE = MEMORY - SELECT SUM(cost) sum_cost, b.item_id, b.warehouse_id, t.tarifa_class - FROM tmp.bionic_component b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - GROUP BY b.item_id, b.warehouse_id, t.tarifa_class; - - -- ***** Inicia Modifica t_bionic_rate las diferentes tarifas - -- Tarifa por unidad minima - DROP TEMPORARY TABLE IF EXISTS t_bionic_rate; - CREATE TEMPORARY TABLE t_bionic_rate - ENGINE = MEMORY - SELECT b.warehouse_id, item_id, 1 rate, - IF(box = 1, `grouping`, 1) `grouping`, SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,1) = 1 AND box < 2 AND (packing > `grouping` or box = 0) - GROUP BY warehouse_id, item_id; - - -- Tarifa por caja - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 2 rate, packing `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE available IS NULL OR (IFNULL(cs.tarifa_class,2) = 2 AND packing > 0 AND available >= packing) - GROUP BY warehouse_id, item_id; - - -- Tarifa para toda la cantidad disponible - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 3 rate, available `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,3) = 3 - GROUP BY warehouse_id, item_id; - - -- ***** Fin Modifica t_bionic_rate las diferentes tarifas - - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_price; - CREATE TEMPORARY TABLE tmp.bionic_price - LIKE template_bionic_price; - - INSERT INTO tmp.bionic_price (warehouse_id, item_id, rate, `grouping`, price) - SELECT * FROM ( - SELECT * FROM t_bionic_rate ORDER BY price - ) t - GROUP BY item_id, warehouse_id, `grouping`; - - - DROP TEMPORARY TABLE IF EXISTS tmp.travel_tree; - CREATE TEMPORARY TABLE tmp.travel_tree - ENGINE = MEMORY - SELECT * FROM tmp.agencyHourGetShipped; - - -- Limpieza - - DROP TEMPORARY TABLE tmp.agencyHourGetShipped; - DROP TEMPORARY TABLE t_bionic_temp; - DROP TEMPORARY TABLE t_component_sum; - DROP TEMPORARY TABLE t_components_base; - DROP TEMPORARY TABLE t_bionic_rate; - DROP TEMPORARY TABLE tmp.bionic_component_copy; +CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_component__`(IN `v_consigna` INT, IN `v_agencia` INT) +proc: BEGIN + + DECLARE v_customer INT; + DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.0; + DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; + DECLARE VOLUMEN_CAJA_VERDNATURA BIGINT; -- DEFAULT 138000; + -- DECLARE vValorEmbolsado DOUBLE DEFAULT 0.04; + + CALL util.THROW('OBSOLETO'); + + SELECT Volumen INTO VOLUMEN_CAJA_VERDNATURA + FROM Cubos + WHERE Id_Cubo = '94'; + + SELECT Id_Cliente INTO v_customer FROM Consignatarios WHERE Id_Consigna = v_consigna; + SET @rate2 := 0; + SET @rate3 := 0; + + DROP TEMPORARY TABLE IF EXISTS t_bionic_temp; + CREATE TEMPORARY TABLE t_bionic_temp + (PRIMARY KEY (item_id,warehouse_id)) + ENGINE = MEMORY + SELECT + b.item_id, b.warehouse_id,available, + IF((@rate2 := IFNULL(pf.rate_2,c.Tarifa2)) < a.PVP AND a.`Min`, a.PVP, @rate2) * 1.0 rate_2, + IF((@rate3 := IFNULL(pf.rate_3,c.Tarifa3)) < a.PVP AND a.`Min`, a.PVP, @rate3) * 1.0 rate_3, + ifnull(pf.rate_3,0) AS min_price, + IFNULL(pf.Packing,c.Packing) packing, + IFNULL(pf.`grouping`,c.`grouping`) `grouping`, + ABS(IFNULL(pf.caja,c.caja)) box, + b.buy_id, a.tipo_id + FROM tmp.bionic_lot b + JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra + JOIN vn2008.Articles a ON b.item_id = a.Id_Article + JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = t.reino_id + LEFT JOIN vn2008.PreciosEspeciales p ON a.Id_Article = p.Id_Article AND p.Id_Cliente = v_customer + LEFT JOIN ( + SELECT * FROM ( + SELECT p.item_id, p.`grouping`, p.Packing, p.caja, p.rate_2, p.rate_3, zgs.warehouseFk AS warehouse_id + FROM vn2008.price_fixed p + JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = p.warehouse_id OR p.warehouse_id = 0 + WHERE zgs.shipped BETWEEN p.date_start AND p.date_end ORDER BY p.item_id, p.warehouse_id DESC + ) t + GROUP BY item_id, warehouse_id + ) pf ON pf.item_id = b.item_id AND pf.warehouse_id = b.warehouse_id + -- descartamos articulos con coste menor de 0.01 + WHERE Costefijo + Portefijo + Embalajefijo + Comisionfija > 0.01 AND r.display <> 0; + + -- Creamos la tabla tmp.bionic_component + DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component; + CREATE TEMPORARY TABLE tmp.bionic_component LIKE + template_bionic_component; + + -- Componentes del precio, valores absolutos + INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) + SELECT b.warehouse_id, b.item_id, 29, rate_3 - Costefijo - Portefijo - Embalajefijo - Comisionfija + FROM t_bionic_temp b + JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; + + INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) + SELECT b.warehouse_id, b.item_id, 28, Costefijo + Portefijo + Embalajefijo + Comisionfija + FROM t_bionic_temp b + JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; + + -- Ahora los valores en funcion de la base + + DROP TEMPORARY TABLE IF EXISTS t_components_base; + + CREATE TEMPORARY TABLE t_components_base + SELECT bc.item_id, ROUND(SUM(cost), 4) AS base, bc.warehouse_id + FROM tmp.bionic_component bc + GROUP BY bc.item_id,warehouse_id; + + -- La ratio se calcula teniendo en cuenta el valor de las reclamaciones y el saldo de greuge + + INSERT INTO tmp.bionic_component + SELECT cb.warehouse_id, item_id, 17, ROUND(base * LEAST(recobro,0.25), 3) + FROM t_components_base cb + JOIN bi.claims_ratio ON Id_Cliente = v_customer + WHERE recobro > 0.009; + + -- PAK 2016-08-31 Componente de maná automático, en función del maná acumulado por el comercial. + + INSERT INTO tmp.bionic_component + SELECT cb.warehouse_id, item_id, 39, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto + FROM t_components_base cb + JOIN Clientes c on c.Id_Cliente = v_customer + JOIN bs.mana_spellers ms ON c.Id_Trabajador = ms.Id_Trabajador + WHERE ms.prices_modifier_activated + AND c.Id_Trabajador != 196 -- Ruben Espinosa + HAVING manaAuto <> 0 ; + + +/* + -- Vendedor variable + INSERT INTO tmp.bionic_component + SELECT cb.warehouse_id, item_id, Id_Componente, IFNULL(ROUND(base * tax,4), 0) + FROM t_components_base cb + JOIN bi.tarifa_componentes + WHERE tarifa_componentes_series_id = 2 and IFNULL(tax, 0) > 0; + */ + + +-- ******* Inicio Bloque para componentes con tarifa_class diferente de NULL + -- Descuento por ultimas unidades + INSERT INTO tmp.bionic_component + SELECT cb.warehouse_id, b.item_id, Id_Componente, GREATEST(IFNULL(ROUND(base * tax,4), 0), b.min_price - b.rate_3) + FROM t_components_base cb + JOIN bi.tarifa_componentes + JOIN t_bionic_temp b ON b.item_id = cb.item_id AND b.warehouse_id = cb.warehouse_id + LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id + WHERE Id_Componente = 32 AND tax <> 0 AND b.min_price < b.rate_3 AND PrecioEspecial IS NULL; + + -- Incremento por paquete suelto + INSERT INTO tmp.bionic_component + SELECT b.warehouse_id, b.item_id, 22, rate_2 - rate_3 + FROM t_bionic_temp b + JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra + LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id + WHERE PrecioEspecial IS NULL; + +-- ******* Fin Bloque para componentes con tarifa_class diferente de NULL + + -- Reparto + INSERT INTO tmp.bionic_component + SELECT b.warehouse_id + , b.item_id + , 15 + , COEFICIENTE_DE_INFLACION_GENERAL + * ROUND( + r.cm3 + * art.compression + * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) + * IFNULL(az.price + * az.inflacion ,50) + / VOLUMEN_CAJA_VERDNATURA, 4 + ) cost + FROM t_bionic_temp b + JOIN vn2008.Articles art ON art.Id_Article = b.item_id + JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia + JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna + JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id + JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id + LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id + HAVING cost <> 0; + +-- Reparto bonificado + INSERT INTO tmp.bionic_component + SELECT b.warehouse_id + , b.item_id + , 41 + , COEFICIENTE_DE_INFLACION_GENERAL + * ROUND( + r.cm3 + * art.compression + * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) + -- * awb.bonus + * az.inflacion + / VOLUMEN_CAJA_VERDNATURA, 4 + ) cost + FROM t_bionic_temp b + JOIN vn2008.Articles art ON art.Id_Article = b.item_id + JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia + JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna + JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id + JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id + -- JOIN vn2008.agency_weekday_bonus awb ON awb.warehouse_id = az.warehouse_id AND awb.zona = az.zona AND a.agency_id = awb.agency_id + LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id + JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = awb.warehouse_id AND weekday(ah.landed) = awb.weekDay + HAVING cost <> 0 + LIMIT 1; + +-- PAK 12-05-2015 + -- EMBOLSADO + IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = v_consigna) THEN + + -- IF v_consigna IN (13690, 3402, 5661, 4233) THEN + + INSERT INTO tmp.bionic_component + SELECT b.warehouse_id, b.item_id, 38, ap.packagingValue cost + FROM t_bionic_temp b + JOIN vn.addressForPackaging ap + WHERE ap.addressFk = v_consigna; + + END IF; + + -- JGF 14-08-2015 + -- Modificacion de precio por dia de preparacion del pedido + INSERT INTO tmp.bionic_component + SELECT cb.warehouse_id, cb.item_id, 14, cb.base * (IFNULL(pe.percentage,pp.percentage)/100) + FROM t_components_base cb + JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = cb.warehouse_id + LEFT JOIN vn2008.preparation_percentage pp ON pp.week_day = weekday(ah.shipped) AND cb.warehouse_id = IFNULL(pp.warehouse_id,cb.warehouse_id) + LEFT JOIN vn2008.preparation_exception pe ON pe.exception_day = ah.shipped AND cb.warehouse_id = IFNULL(pe.warehouse_id,cb.warehouse_id) + WHERE IFNULL(pe.percentage,pp.percentage); + + -- Creamos la tabla tmp.bionic_component_copy por que mysql no puede reabrir una tabla temporal + DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component_copy; + CREATE TEMPORARY TABLE tmp.bionic_component_copy + SELECT * FROM tmp.bionic_component; + + -- JGF 19-01-2016 + -- Precios especiales + INSERT INTO tmp.bionic_component + SELECT b.warehouse_id, b.item_id, 10, pe.PrecioEspecial - SUM(cost) sum_cost + FROM tmp.bionic_component_copy b + JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente + JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id + WHERE t.tarifa_class IS NULL + GROUP BY b.item_id, b.warehouse_id + HAVING ABS(sum_cost) > 0.001; + + -- Lotes + DROP TEMPORARY TABLE IF EXISTS t_component_sum; + CREATE TEMPORARY TABLE t_component_sum + (INDEX (item_id, warehouse_id)) + ENGINE = MEMORY + SELECT SUM(cost) sum_cost, b.item_id, b.warehouse_id, t.tarifa_class + FROM tmp.bionic_component b + JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente + GROUP BY b.item_id, b.warehouse_id, t.tarifa_class; + + -- ***** Inicia Modifica t_bionic_rate las diferentes tarifas + -- Tarifa por unidad minima + DROP TEMPORARY TABLE IF EXISTS t_bionic_rate; + CREATE TEMPORARY TABLE t_bionic_rate + ENGINE = MEMORY + SELECT b.warehouse_id, item_id, 1 rate, + IF(box = 1, `grouping`, 1) `grouping`, SUM(sum_cost) price + FROM t_bionic_temp b + JOIN t_component_sum cs USING(item_id, warehouse_id) + WHERE IFNULL(cs.tarifa_class,1) = 1 AND box < 2 AND (packing > `grouping` or box = 0) + GROUP BY warehouse_id, item_id; + + -- Tarifa por caja + INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) + SELECT b.warehouse_id, item_id, 2 rate, packing `grouping`, + SUM(sum_cost) price + FROM t_bionic_temp b + JOIN t_component_sum cs USING(item_id, warehouse_id) + WHERE available IS NULL OR (IFNULL(cs.tarifa_class,2) = 2 AND packing > 0 AND available >= packing) + GROUP BY warehouse_id, item_id; + + -- Tarifa para toda la cantidad disponible + INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) + SELECT b.warehouse_id, item_id, 3 rate, available `grouping`, + SUM(sum_cost) price + FROM t_bionic_temp b + JOIN t_component_sum cs USING(item_id, warehouse_id) + WHERE IFNULL(cs.tarifa_class,3) = 3 + GROUP BY warehouse_id, item_id; + + -- ***** Fin Modifica t_bionic_rate las diferentes tarifas + + DROP TEMPORARY TABLE IF EXISTS tmp.bionic_price; + CREATE TEMPORARY TABLE tmp.bionic_price + LIKE template_bionic_price; + + INSERT INTO tmp.bionic_price (warehouse_id, item_id, rate, `grouping`, price) + SELECT * FROM ( + SELECT * FROM t_bionic_rate ORDER BY price + ) t + GROUP BY item_id, warehouse_id, `grouping`; + + + DROP TEMPORARY TABLE IF EXISTS tmp.travel_tree; + CREATE TEMPORARY TABLE tmp.travel_tree + ENGINE = MEMORY + SELECT * FROM tmp.agencyHourGetShipped; + + -- Limpieza + + DROP TEMPORARY TABLE tmp.agencyHourGetShipped; + DROP TEMPORARY TABLE t_bionic_temp; + DROP TEMPORARY TABLE t_component_sum; + DROP TEMPORARY TABLE t_components_base; + DROP TEMPORARY TABLE t_bionic_rate; + DROP TEMPORARY TABLE tmp.bionic_component_copy; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66261,7 +68440,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 `bionic_calc_movement` */; +/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_movement_okKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -66271,7 +68450,74 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_movement`(IN v_id_mov BIGINT ) +CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_movement_okKk`(IN v_ticket BIGINT) +BEGIN + +/* +Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo +*/ + DECLARE v_shipment DATE; + DECLARE v_customer INT; + DECLARE v_wh SMALLINT; + DECLARE v_agencia INT; + DECLARE v_consigna INT; + DECLARE v_landing DATE; + + SELECT Id_Cliente , t.warehouse_id, date(t.Fecha), Id_Consigna , Id_Agencia + INTO v_customer ,v_wh, v_shipment , v_consigna , v_agencia + FROM vn2008.Agencias a + JOIN vn2008.Tickets t using(Id_Agencia) + WHERE Id_Ticket = v_ticket; + + DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; + CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ENGINE = MEMORY + SELECT v_wh warehouseFk, v_shipment shipped, v_landing landed; + + CALL item_last_buy_ (v_wh, v_shipment); -- rellena la tabla t_item_last_buy con la ultima compra + + DROP TEMPORARY TABLE IF EXISTS tmp.bionic_lot; + CREATE TEMPORARY TABLE tmp.bionic_lot + SELECT v_wh warehouse_id,NULL available, + m.Id_Article item_id,ilb.buy_id + FROM Movimientos m + LEFT JOIN t_item_last_buy ilb ON ilb.item_id = m.Id_Article + WHERE m.Id_Ticket = v_ticket GROUP BY m.Id_Article; + + CALL bionic_calc_component(v_consigna,v_agencia); + + DROP TEMPORARY TABLE IF EXISTS tmp.movement; + CREATE TEMPORARY TABLE tmp.movement + (PRIMARY KEY (Id_Movimiento)) ENGINE = MEMORY + SELECT Id_Movimiento, v_wh warehouse_id FROM Movimientos m WHERE m.Id_Ticket = v_ticket; + CALL bionic_movement_update(1); + + -- Log + call Ditacio(v_ticket + ,'Bioniza Lineas OK' + ,'T' + , 20 + , 'proc bionic_calc_movement_ok ' + , NULL); + + -- Limpieza + 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 `bionic_calc_movement__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_movement__`(IN v_id_mov BIGINT ) proc: BEGIN /* @@ -66352,73 +68598,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_movement_okKk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_movement_okKk`(IN v_ticket BIGINT) -BEGIN - -/* -Este procedimiento "rebioniza" una linea, eliminando los componentes existentes e insertandolos de nuevo -*/ - DECLARE v_shipment DATE; - DECLARE v_customer INT; - DECLARE v_wh SMALLINT; - DECLARE v_agencia INT; - DECLARE v_consigna INT; - DECLARE v_landing DATE; - - SELECT Id_Cliente , t.warehouse_id, date(t.Fecha), Id_Consigna , Id_Agencia - INTO v_customer ,v_wh, v_shipment , v_consigna , v_agencia - FROM vn2008.Agencias a - JOIN vn2008.Tickets t using(Id_Agencia) - WHERE Id_Ticket = v_ticket; - - DROP TEMPORARY TABLE IF EXISTS tmp.agencyHourGetShipped; - CREATE TEMPORARY TABLE tmp.agencyHourGetShipped ENGINE = MEMORY - SELECT v_wh warehouseFk, v_shipment shipped, v_landing landed; - - CALL item_last_buy_ (v_wh, v_shipment); -- rellena la tabla t_item_last_buy con la ultima compra - - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_lot; - CREATE TEMPORARY TABLE tmp.bionic_lot - SELECT v_wh warehouse_id,NULL available, - m.Id_Article item_id,ilb.buy_id - FROM Movimientos m - LEFT JOIN t_item_last_buy ilb ON ilb.item_id = m.Id_Article - WHERE m.Id_Ticket = v_ticket GROUP BY m.Id_Article; - - CALL bionic_calc_component(v_consigna,v_agencia); - - DROP TEMPORARY TABLE IF EXISTS tmp.movement; - CREATE TEMPORARY TABLE tmp.movement - (PRIMARY KEY (Id_Movimiento)) ENGINE = MEMORY - SELECT Id_Movimiento, v_wh warehouse_id FROM Movimientos m WHERE m.Id_Ticket = v_ticket; - CALL bionic_movement_update(1); - - -- Log - call Ditacio(v_ticket - ,'Bioniza Lineas OK' - ,'T' - , 20 - , 'proc bionic_calc_movement_ok ' - , NULL); - - -- Limpieza - 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 `bionic_calc_reverseKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -70436,6 +72615,139 @@ BEGIN DECLARE vNewTicket INT; DECLARE vYear INT; + DECLARE rsTicket CURSOR FOR + SELECT tt.Id_Ticket, weekDay, Id_Cliente, warehouse_id, empresa_id, Id_Consigna, Id_Agencia + FROM Tickets_turno tt + JOIN Tickets t ON tt.Id_Ticket = t.Id_Ticket; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; + + SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0); + + OPEN rsTicket; + + myLoop: LOOP + BEGIN + DECLARE vError TEXT; + DECLARE vSalesPersonEmail VARCHAR(150); + DECLARE vMailSent BOOL; + DECLARE vSubject VARCHAR(150); + DECLARE vMessage TEXT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + GET DIAGNOSTICS CONDITION 1 + vError = MESSAGE_TEXT; + + END; + + SET vIsDone = FALSE; + FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vConsignatario, vAgencia; + + IF vIsDone THEN + LEAVE myLoop; + END IF; + SELECT date INTO vShipment + FROM time + WHERE year = vYear AND week = vWeek + AND WEEKDAY(date) = vWeekDay; + + -- busca si el ticket ya ha sido clonado + IF (select count(*) FROM Tickets t JOIN ticket_observation tob ON t.Id_Ticket = tob.Id_Ticket + WHERE Id_Consigna = vConsignatario AND DATE(Fecha) = vShipment AND tob.text LIKE CONCAT('%',vTicket,'%')) = 0 + THEN + + CALL vn.zoneGetLanded(vShipment, vConsignatario, vAgencia, vWarehouse); + + SELECT landed INTO vLanding from tmp.zoneGetLanded; + IF (SELECT COUNT(*) FROM Agencias WHERE Id_Agencia = vAgencia AND Agencia LIKE '%turno%') THEN + SET vAgencia = NULL; + END IF; + + CALL vn.ticketCreateWithoutZone(vClient, vShipment, vWarehouse, vEmpresa, vConsignatario, vAgencia, NULL, vLanding,account.userGetId(), vNewTicket); + + IF (vLanding IS NULL) THEN + + SELECT e.email INTO vSalesPersonEmail + FROM vn.client c + JOIN vn.worker sp ON sp.id = c.salesPersonFk + JOIN account.emailUser e ON e.userFk = sp.userFk + WHERE c.id = vClient; + + SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicket, + ' para el dia: ', vShipment); + SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicket, + ' para el dia: ', vShipment, + ' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket, + ' pero ha que revisar las fechas y la agencia'); + + SELECT COUNT(*) INTO vMailSent + FROM vn.mail + WHERE sender = vSalesPersonEmail + AND subject = vSubject; + + IF NOT vMailSent THEN + INSERT INTO vn2008.mail (`to`,`subject`,`text`) + VALUES (vSalesPersonEmail, vSubject, vMessage); + END IF; + CALL vn.ticketStateUpdate (vNewTicket, 'FIXING'); + END IF; + + INSERT INTO Movimientos (Id_Ticket, Id_Article, Concepte, Cantidad, Preu, Descuento, CostFixat, PrecioFijado) + SELECT vNewTicket, Id_Article, Concepte, Cantidad, Preu, Descuento, CostFixat, PrecioFijado + FROM Movimientos WHERE Id_Ticket = vTicket; + + INSERT INTO Ordenes (orden,datorden,datticket,codvendedor,codcomprador,cantidad,preciomax,preu,id_article,id_cliente,comentario, + ok, total,datcompra,ko,id_movimiento) + SELECT o.orden,o.datorden,vShipment,o.codvendedor,o.codcomprador,o.cantidad,o.preciomax,o.preu,o.id_article,o.id_cliente,o.comentario, + o.ok, o.total,o.datcompra,o.ko,m2.Id_Movimiento + FROM Movimientos m JOIN Ordenes o ON o.Id_Movimiento = m.Id_Movimiento + JOIN Movimientos m2 ON m.Concepte = m2.Concepte AND m.Cantidad = m2.Cantidad AND m.Id_Article = m2.Id_Article + WHERE m.Id_Ticket = vTicket AND m2.Id_Ticket = vNewTicket; + + INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicket)) + ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' '); + + INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,1,'ATENCION: Contiene lineas de TURNO') + ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' '); + + CALL vn.ticketCalculateClon(vNewTicket, vTicket); + END IF; + END; + END LOOP; + + CLOSE rsTicket; + +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 `clonWeeklyTickets__` */; +/*!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 `clonWeeklyTickets__`(IN vWeek INT) +BEGIN + DECLARE vIsDone BOOL; + DECLARE vLanding DATE; + DECLARE vShipment DATE; + DECLARE vWarehouse INT; + DECLARE vTicket INT; + DECLARE vWeekDay INT; + DECLARE vClient INT; + DECLARE vEmpresa INT; + DECLARE vConsignatario INT; + DECLARE vAgencia INT; + DECLARE vNewTicket INT; + DECLARE vYear INT; + DECLARE rsTicket CURSOR FOR SELECT tt.Id_Ticket, weekDay, Id_Cliente, warehouse_id, empresa_id, Id_Consigna, Id_Agencia FROM Tickets_turno tt @@ -71032,10 +73344,8 @@ BEGIN CALL article_multiple_buy_date (v_date, i_wh); - END IF; - DROP TEMPORARY TABLE IF EXISTS wtable; CREATE TEMPORARY TABLE wtable ( @@ -71050,12 +73360,10 @@ BEGIN UNTIL i = 7 END REPEAT; - SELECT cy, ly INTO w1, y1 FROM wtable limit 1; SELECT cy, ly INTO w2, y2 FROM wtable WHERE cy > w1 limit 1; SELECT cy, ly INTO w3, y3 FROM wtable WHERE cy > w2 limit 1; SELECT cy, ly INTO w4, y4 FROM wtable WHERE cy > w3 limit 1; - SELECT cy, ly INTO w5, y5 FROM wtable WHERE cy > w4 limit 1; SELECT cy, ly INTO w6, y6 FROM wtable WHERE cy > w5 limit 1; SELECT cy, ly INTO w7, y7 FROM wtable WHERE cy > w6 limit 1; @@ -71193,6 +73501,8 @@ BEGIN DROP TEMPORARY TABLE last_year; DROP TEMPORARY TABLE cur_year; DROP TEMPORARY TABLE article_inventory; + DROP TEMPORARY TABLE wtable; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -71608,9 +73918,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -71635,6 +73945,7 @@ BEGIN m.Concepte, ABS(m.Reservado) Reservado, i.Categoria, + tp.Tipo, t.Alias as Cliente, wh.name as Almacen, t.warehouse_id, @@ -73419,41 +75730,8 @@ SELECT C.calidad, LEFT(Article, 4) as Subtipo, barcode, 'ASEGURADO' AS asegurado, -/*CASE A.tipo_id -WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),'RAMAJE',R.Reino) -WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),'RAMAJE',R.Reino) -WHEN 69 THEN IF(M.Id_Article IN (41),'RAMAJE',R.Reino) -WHEN 72 THEN IF(M.Id_Article IN (238),'RAMAJE',R.Reino) -WHEN 2 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 122 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 12 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 13 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 14 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 15 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 71 THEN IF(LEFT(Article,2) = 'HC','Flor',R.Reino) -WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),'CYMBIDIUMS & ANTHURIUMS',R.Reino) -WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%','CYMBIDIUMS & ANTHURIUMS',R.Reino) -WHEN 86 THEN 'Flor' -ELSE R.Reino -END as*/ Reino, - /* -CASE A.tipo_id -WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),-1,R.orden) -WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),-1,R.orden) -WHEN 69 THEN IF(M.Id_Article IN (41),-1,R.orden) -WHEN 72 THEN IF(M.Id_Article IN (238),-1,R.orden) -WHEN 2 THEN 0 -WHEN 122 THEN 0 -WHEN 12 THEN 0 -WHEN 13 THEN 0 -WHEN 14 THEN 0 -WHEN 15 THEN 0 -WHEN 71 THEN IF(LEFT(Article,2) = 'HC',1,R.orden) -WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),0,R.orden) -WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%',0,R.orden) -WHEN 86 THEN 1 -ELSE R.orden -END as*/R.orden, + Reino, + R.orden, CS.Consignatario, T.Id_Cliente, NULL AS Id_Trabajador, @@ -73463,7 +75741,7 @@ END as*/R.orden, M.Cantidad, M.quantity, M.Cantidad / IF(nz(Gro.`Grouping`) = 0,1,nz(Gro.`Grouping`)) as Paquetes, - IF(sis.vHasBeenPrepared, CONCAT(' ----- PREPARADO ----- ', M.Concepte), M.Concepte) as Concepte, + IFNULL(CONCAT(iss.sectorCode, ' ', M.Concepte), M.Concepte) as Concepte, A.Medida, A.Color, A.Categoria, @@ -73479,7 +75757,7 @@ END as*/R.orden, A.Tallos, Gro.`Grouping`, IF(`transaction`,right(concat('000000' ,M.Id_Article),6),M.Id_Movimiento) Id_Movimiento, - IF(sis.vHasBeenPrepared,'RES',an.Nicho) as Nicho, + IFNULL(iss.pickingPlacement,an.Nicho) as Nicho, 'PEDIDO ASEGURADO' AS MSG, T.Id_Ruta, RT.Id_Vehiculo, @@ -73488,7 +75766,7 @@ END as*/R.orden, group_concat(IF(observation_type_id = 2,text,'') SEPARATOR '') 'encajador', A.Foto, M.Id_Movimiento movement_id, - lpad(IF(sis.vHasBeenPrepared,99999,ifnull(cooler_path_detail_id, an.Nicho)),5,'0') as path, + lpad(IFNULL(iss.path,ifnull(cooler_path_detail_id, an.Nicho)),5,'0') as path, M.Descuento,M.Preu, mm.valor as Preparado, mm.original_quantity , p.`name` producer, T.warehouse_id, @@ -73499,12 +75777,19 @@ FROM Tickets T LEFT JOIN Movimientos M USING(Id_Ticket) - LEFT JOIN (SELECT DISTINCT saleFk, TRUE as vHasBeenPrepared - FROM vn.saleItemShelving sis - JOIN vn.sale s ON s.id = sis.saleFk - WHERE s.ticketFk = idT - AND sis.quantity > 0 - ) sis ON sis.saleFk = M.Id_Movimiento + LEFT JOIN ( SELECT saleFk, + sc.code as sectorCode, + sc.pickingPlacement, + sc.path, + TRUE as vHasBeenPrepared + FROM vn.itemShelvingSale iss + JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector sc ON sc.id =p.sectorFk + WHERE iss.created > CURDATE() + AND iss.quantity > 0 + ) iss ON iss.saleFk = M.Id_Movimiento LEFT JOIN Articles A on A.Id_Article = M.Id_Article LEFT JOIN Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = T.warehouse_id LEFT JOIN producer p on p.producer_id = A.producer_id -- JGF 2016-02-16 @@ -73651,6 +75936,158 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `F5__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `F5__`(IN `idT` BIGINT) +BEGIN +SELECT C.calidad, + LEFT(Article, 4) as Subtipo, + barcode, + 'ASEGURADO' AS asegurado, +/*CASE A.tipo_id +WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),'RAMAJE',R.Reino) +WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),'RAMAJE',R.Reino) +WHEN 69 THEN IF(M.Id_Article IN (41),'RAMAJE',R.Reino) +WHEN 72 THEN IF(M.Id_Article IN (238),'RAMAJE',R.Reino) +WHEN 2 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 122 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 12 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 13 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 14 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 15 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 71 THEN IF(LEFT(Article,2) = 'HC','Flor',R.Reino) +WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),'CYMBIDIUMS & ANTHURIUMS',R.Reino) +WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%','CYMBIDIUMS & ANTHURIUMS',R.Reino) +WHEN 86 THEN 'Flor' +ELSE R.Reino +END as*/ Reino, + /* +CASE A.tipo_id +WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),-1,R.orden) +WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),-1,R.orden) +WHEN 69 THEN IF(M.Id_Article IN (41),-1,R.orden) +WHEN 72 THEN IF(M.Id_Article IN (238),-1,R.orden) +WHEN 2 THEN 0 +WHEN 122 THEN 0 +WHEN 12 THEN 0 +WHEN 13 THEN 0 +WHEN 14 THEN 0 +WHEN 15 THEN 0 +WHEN 71 THEN IF(LEFT(Article,2) = 'HC',1,R.orden) +WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),0,R.orden) +WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%',0,R.orden) +WHEN 86 THEN 1 +ELSE R.orden +END as*/R.orden, + CS.Consignatario, + T.Id_Cliente, + NULL AS Id_Trabajador, + T.Id_Ticket, + T.Fecha, + M.Id_Article, + M.Cantidad, + M.quantity, + M.Cantidad / IF(nz(Gro.`Grouping`) = 0,1,nz(Gro.`Grouping`)) as Paquetes, + IF(sis.vHasBeenPrepared, CONCAT(' ----- PREPARADO ----- ', M.Concepte), M.Concepte) as Concepte, + A.Medida, + A.Color, + A.Categoria, + O.Abreviatura as Origen, + T.Localizacion, + CT.CodigoTrabajador as Vendedor, + T.Bultos, + T.Observaciones, + Ag.Agencia Tipo, + NULL AS CodigoTrabajador, + M.OK, + M.Reservado, + A.Tallos, + Gro.`Grouping`, + IF(`transaction`,right(concat('000000' ,M.Id_Article),6),M.Id_Movimiento) Id_Movimiento, + IF(sis.vHasBeenPrepared,'RES',an.Nicho) as Nicho, + 'PEDIDO ASEGURADO' AS MSG, + T.Id_Ruta, + RT.Id_Vehiculo, + observation_type_id, + group_concat(IF(observation_type_id = 1,text,'') SEPARATOR '') 'sacador', + group_concat(IF(observation_type_id = 2,text,'') SEPARATOR '') 'encajador', + A.Foto, + M.Id_Movimiento movement_id, + lpad(IF(sis.vHasBeenPrepared,99999,ifnull(cooler_path_detail_id, an.Nicho)),5,'0') as path, + M.Descuento,M.Preu, mm.valor as Preparado, mm.original_quantity + , p.`name` producer, + T.warehouse_id, + ST.id as idStowaway, + STP.shipFk as isStowaway, + CS.POBLACION -- JGF 2016-02-16 +FROM + + Tickets T + LEFT JOIN Movimientos M USING(Id_Ticket) + LEFT JOIN (SELECT DISTINCT saleFk, TRUE as vHasBeenPrepared + FROM vn.saleItemShelving sis + JOIN vn.sale s ON s.id = sis.saleFk + WHERE s.ticketFk = idT + AND sis.quantity > 0 + ) sis ON sis.saleFk = M.Id_Movimiento + LEFT JOIN Articles A on A.Id_Article = M.Id_Article + LEFT JOIN Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = T.warehouse_id + LEFT JOIN producer p on p.producer_id = A.producer_id -- JGF 2016-02-16 + LEFT JOIN cooler_path_detail c on left(an.Nicho,3) = pasillo + LEFT JOIN Origen O ON A.id_origen = O.id + LEFT JOIN Clientes C USING(Id_Cliente) + LEFT JOIN Trabajadores CT ON C.Id_Trabajador = CT.Id_Trabajador + INNER JOIN Consignatarios CS ON T.Id_Consigna = CS.Id_Consigna + INNER JOIN Agencias Ag ON Ag.Id_Agencia = T.Id_Agencia + LEFT JOIN ( + SELECT Id_Article, code as barcode + FROM barcodes + GROUP BY Id_Article + ) BC ON BC.Id_Article = A.Id_Article + LEFT JOIN Tipos TP USING(tipo_id) + LEFT JOIN reinos R ON TP.reino_id = R.id + LEFT JOIN Rutas RT USING(Id_Ruta) + LEFT JOIN ticket_observation tobs ON T.Id_Ticket = tobs.Id_ticket + AND (tobs.observation_type_id = 1 or tobs.observation_type_id = 2) + + LEFT JOIN ( + SELECT Id_Article, `Grouping` + FROM ( + SELECT landing, Id_Article, CASE caja + WHEN 0 THEN 1 + WHEN 2 THEN Packing + ELSE `Grouping` + END as `Grouping` + FROM Compres C + JOIN Entradas E USING(Id_Entrada) + JOIN travel TR ON TR.id = travel_id + WHERE warehouse_id = (SELECT warehouse_id FROM Tickets WHERE Id_Ticket = idT) + AND landing between (SELECT FechaInventario FROM tblContadores LIMIT 1) AND (SELECT date(Fecha) FROM Tickets WHERE Id_Ticket = idT) + ORDER BY landing DESC + ) GR1 + GROUP BY Id_Article + + ) Gro ON Gro.Id_Article = M.Id_Article + LEFT JOIN Movimientos_mark mm ON mm.Id_Movimiento = M.Id_Movimiento + LEFT JOIN vn.stowaway ST ON ST.shipFk = idT + LEFT JOIN vn.stowaway STP on STP.id = idT + + WHERE T.Id_Ticket = idT + group by M.Id_Movimiento; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `Facturas_Saltos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75645,7 +78082,7 @@ proc: BEGIN 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_end = TIMESTAMP(TIMESTAMPADD(DAY, IFNULL(days_max,15), date_ticket),'23:59:59'); SET date_top = TIMESTAMPADD(DAY, 1,date_end); IF date_ticket <= CURDATE() THEN @@ -76506,7 +78943,199 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `inventario_valorado`(IN d_FEC DATE, IN bol_DESGLOSE BOOLEAN) +CREATE DEFINER=`root`@`%` PROCEDURE `inventario_valorado`(IN vDated DATE, IN vIsDetailed BOOLEAN) +BEGIN + + DECLARE vInventoried DATE; + DECLARE vHasNotInventory BOOLEAN DEFAULT 0; + DECLARE vInventoried2 DATE; + DECLARE vDateDayEnd DATETIME; + + SET vDateDayEnd = util.dayEnd(vDated); + SELECT landing INTO vInventoried + FROM travel tr + JOIN Entradas E ON E.travel_id = tr.id + WHERE landing <= vDateDayEnd + AND E.Id_Proveedor = 4 + ORDER BY landing DESC + LIMIT 1; + + SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE); + + IF vHasNotInventory THEN + + SELECT landing INTO vInventoried2 + FROM travel tr + JOIN Entradas E ON E.travel_id = tr.id + WHERE landing >= vDated + AND E.Id_Proveedor = 4 + ORDER BY landing ASC + LIMIT 1; + + SET vInventoried = TIMESTAMPADD(DAY,1,vDated); + SET vDateDayEnd = vInventoried2; + + END IF; + + DROP TEMPORARY TABLE IF EXISTS inv; + + CREATE TEMPORARY TABLE inv + (warehouseFk SMALLINT, + Id_Article BIGINT, + cantidad INT, + coste DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + Almacen VARCHAR(20), + PRIMARY KEY (Almacen, Id_Article) USING HASH) + ENGINE = MEMORY; + + IF vHasNotInventory = TRUE THEN + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouse_id, C.Id_Article, SUM(C.Cantidad), w.`name` + FROM Compres C + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING (Id_Entrada) + JOIN travel tr ON tr.id = E.travel_id + JOIN Tipos t USING(tipo_id) + JOIN warehouse w ON w.id = warehouse_id + WHERE landing = vDateDayEnd + AND E.Id_Proveedor = 4 + AND w.valuatedInventory + AND t.inventory + GROUP BY tr.warehouse_id, C.Id_Article; + + END IF; + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouse_id, C.Id_Article, C.Cantidad * IF(vHasNotInventory,-1,1), w.`name` + FROM Compres C + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING (Id_Entrada) + JOIN travel tr ON tr.id = E.travel_id + JOIN Tipos t USING(tipo_id) + JOIN warehouse w ON w.id = tr.warehouse_id + WHERE landing BETWEEN vInventoried AND vDateDayEnd + AND IF(landing = CURDATE(), tr.received, trUE) + AND NOT redada + AND w.valuatedInventory + AND t.inventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad * IF(vHasNotInventory,-1,1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouse_id_out, C.Id_Article, C.Cantidad * IF(vHasNotInventory,1,-1), w.`name` + FROM Compres C + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING (Id_Entrada) + JOIN travel tr ON tr.id = E.travel_id + JOIN Tipos t USING(tipo_id) + JOIN warehouse w ON w.id = warehouse_id_out + WHERE shipment BETWEEN vInventoried AND vDateDayEnd + AND NOT redada + AND w.valuatedInventory + AND t.inventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad * IF(vHasNotInventory,1,-1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, M.Id_Article, M.Cantidad * IF(vHasNotInventory,1,-1), w.`name` + FROM Movimientos M + JOIN Tickets T USING (Id_Ticket) + JOIN Clientes C USING(Id_Cliente) + JOIN Articles A USING(Id_Article) + JOIN Tipos t USING(tipo_id) + JOIN warehouse w ON w.id = warehouse_id + WHERE T.Fecha BETWEEN vInventoried AND vDateDayEnd + AND w.valuatedInventory + AND t.inventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + M.Cantidad * IF(vHasNotInventory,1,-1); + + IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, M.Id_Article, M.Cantidad * IF(vHasNotInventory,0,1), w.`name` + FROM Movimientos M + JOIN Tickets T USING (Id_Ticket) + JOIN Clientes C USING(Id_Cliente) + JOIN Articles A USING(Id_Article) + JOIN Tipos t USING(tipo_id) + JOIN warehouse w ON w.id = warehouse_id + WHERE T.Fecha BETWEEN vDated AND vDateDayEnd + AND (M.OK <> 0 or T.Etiquetasemitidas <> 0 ) + AND w.valuatedInventory + AND t.inventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + M.Cantidad * IF(vHasNotInventory,0,1); + + END IF; + + -- Mercancia en transito + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouse_id, C.Id_Article, C.Cantidad, CONCAT(wOut.`name`,' - ', wIn.`name`) + FROM Compres C + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING (Id_Entrada) + JOIN travel tr ON tr.id = E.travel_id + JOIN Tipos t USING(tipo_id) + JOIN warehouse wIn ON wIn.id = tr.warehouse_id + JOIN warehouse wOut ON wOut.id = tr.warehouse_id_out + WHERE vInventoried >= shipment AND vInventoried < landing + AND NOT redada + AND wIn.valuatedInventory + AND t.inventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad); + + CALL vn.buyUltimate(NULL,vDateDayEnd); + + UPDATE inv i + JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.Id_Article = bu.itemFk + JOIN Compres C ON C.Id_Compra = bu.buyFk + SET total = i.cantidad * (ifnull(C.Costefijo,0) + IFNULL(C.Embalajefijo,0) + IFNULL(C.Portefijo,0) + IFNULL(C.Comisionfija,0)), + coste = ifnull(C.Costefijo,0) + IFNULL(C.Embalajefijo,0) + IFNULL(C.Portefijo,0) + IFNULL(C.Comisionfija,0) + WHERE i.cantidad <> 0; + + DELETE FROM inv WHERE Cantidad IS NULL or Cantidad = 0; + + IF vIsDetailed THEN + + SELECT inv.warehouseFk, a.Id_Article, a.Article, a.Medida, inv.Cantidad, tp.Id_Tipo, + tp.reino_id, inv.coste, cast(inv.total as decimal(10,2)) total, an.nicho, Almacen + FROM inv + JOIN warehouse w on w.id = warehouseFk + JOIN Articles a ON a.Id_Article = inv.Id_Article + JOIN Tipos tp ON tp.tipo_id = a.tipo_id + JOIN Articles_nicho an ON an.Id_Article = a.Id_Article AND an.warehouse_id = w.id + WHERE w.valuatedInventory + and inv.total > 0 + order by inv.total desc; + + ELSE + + SELECT i.Almacen, r.reino as Reino, cast(i.total as decimal) as Euros, tr.Codigotrabajador as Comprador, + A.Id_Article + FROM inv i + JOIN Articles A USING(Id_Article) + JOIN Tipos t USING(tipo_id) + LEFT JOIN Trabajadores tr ON tr.Id_trabajador = t.Id_trabajador + JOIN reinos r ON r.id = t.reino_id; + + END IF; + DROP TEMPORARY TABLE tmp.buyUltimate; +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_valorado__` */; +/*!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_valorado__`(IN d_FEC DATE, IN bol_DESGLOSE BOOLEAN) BEGIN DECLARE d_INV DATE; @@ -76542,18 +79171,15 @@ BEGIN END IF; DROP TEMPORARY TABLE IF EXISTS inv; - + CREATE TEMPORARY TABLE inv (w_id SMALLINT, Id_Article BIGINT, cantidad INT, coste DOUBLE DEFAULT 0, - total DOUBLE DEFAULT 0) ENGINE = MEMORY; - - - ALTER TABLE inv ADD PRIMARY KEY USING HASH (w_id, Id_Article); - - + total DOUBLE DEFAULT 0, + PRIMARY KEY (w_id, Id_Article) USING HASH) + ENGINE = MEMORY; IF bolREVERSE = 1 THEN @@ -77036,6 +79662,169 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `item_stock_visible`(v_wh SMALLINT, v_item INT) +BEGIN + + DECLARE v_tomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, CURDATE()); + + INSERT INTO tmp_item (item_id, visible) + SELECT item_id, SUM(amount) amount + FROM ( + SELECT item_id, amount + FROM item_out i + LEFT JOIN vn.ticketState ts ON ts.ticketFk = i.ticketFk + JOIN vn.state s ON s.id = ts.stateFk + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + WHERE st.created > CURDATE() + AND (s.isPicked OR st.isChecked) + ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE warehouse_id = v_wh + AND (s.order > 6 OR i.Reservado OR stPrevious.saleFk ) + AND i.dat >= CURDATE() AND i.dat < v_tomorrow + UNION ALL + 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()*/) + AND iei.dat >= CURDATE() AND iei.dat < v_tomorrow + AND iei.warehouse_id = v_wh + AND (v_item IS NULL OR iei.item_id = v_item) + AND iei.isVirtualStock is FALSE + UNION ALL + SELECT item_id, amount FROM item_entry_out + WHERE delivered != FALSE + AND dat >= CURDATE() AND dat < v_tomorrow + AND warehouse_id = v_wh + AND (v_item IS NULL OR item_id = v_item) + ) t + GROUP BY item_id + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock,0) + VALUES(visible); +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 `item_stock_visibleTest` */; +/*!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 `item_stock_visibleTest`(v_wh SMALLINT, v_item INT) +BEGIN + + DECLARE v_tomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, CURDATE()); + + INSERT INTO tmp_item (item_id, visible) + SELECT item_id, SUM(amount) amount + FROM ( + SELECT item_id, amount + FROM item_out i + LEFT JOIN vn.ticketState ts ON ts.ticketFk = i.ticketFk + JOIN vn.state s ON s.id = ts.stateFk + LEFT JOIN (SELECT DISTINCT saleFk FROM vn.saleTracking WHERE created> CURDATE() ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE warehouse_id = v_wh + AND (s.order > 4 OR i.Reservado OR stPrevious.saleFk IS NOT NULL) + AND i.dat >= CURDATE() AND i.dat < v_tomorrow + UNION ALL + 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()*/) + AND iei.dat >= CURDATE() AND iei.dat < v_tomorrow + AND iei.warehouse_id = v_wh + AND (v_item IS NULL OR iei.item_id = v_item) + AND iei.isVirtualStock is FALSE + UNION ALL + SELECT item_id, amount FROM item_entry_out + WHERE delivered != FALSE + AND dat >= CURDATE() AND dat < v_tomorrow + AND warehouse_id = v_wh + AND (v_item IS NULL OR item_id = v_item) + ) t + GROUP BY item_id + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock,0) + VALUES(visible); +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 `item_stock_visible_BETA` */; +/*!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 `item_stock_visible_BETA`(v_wh SMALLINT, v_item INT) +BEGIN + + DECLARE v_tomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, CURDATE()); + + INSERT INTO tmp_item (item_id, visible) + SELECT item_id, SUM(amount) amount + FROM ( + SELECT item_id, amount + FROM item_out i + LEFT JOIN vn.ticketState ts ON ts.ticketFk = i.ticketFk + JOIN vn.state s ON s.id = ts.stateFk + LEFT JOIN (SELECT DISTINCT saleFk + FROM vn.saleTracking st + JOIN vn.state s ON s.id = st.stateFk + WHERE st.created > CURDATE() + AND s.isPicked + ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE warehouse_id = v_wh + AND (s.order > 5 OR i.Reservado OR stPrevious.saleFk OR i.ok ) + AND i.dat >= CURDATE() AND i.dat < v_tomorrow + UNION ALL + 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()*/) + AND iei.dat >= CURDATE() AND iei.dat < v_tomorrow + AND iei.warehouse_id = v_wh + AND (v_item IS NULL OR iei.item_id = v_item) + AND iei.isVirtualStock is FALSE + UNION ALL + SELECT item_id, amount FROM item_entry_out + WHERE delivered != FALSE + AND dat >= CURDATE() AND dat < v_tomorrow + AND warehouse_id = v_wh + AND (v_item IS NULL OR item_id = v_item) + ) t + GROUP BY item_id + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock,0) + VALUES(visible); +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 `item_stock_visible__` */; +/*!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 `item_stock_visible__`(v_wh SMALLINT, v_item INT) BEGIN DECLARE v_curdate DATETIME DEFAULT TIMESTAMP(CURDATE(), '00:00:00'); DECLARE v_tomorrow DATETIME DEFAULT TIMESTAMPADD(HOUR, 24, CURDATE()); @@ -79280,7 +82069,8 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buffer_problems; CREATE TEMPORARY TABLE tmp.buffer_problems ( Id_Ticket INT(11), - problem VARCHAR(50), + problem VARCHAR(255), + `order` INT(11) DEFAULT 10, INDEX (Id_Ticket) ) ENGINE = MEMORY; @@ -79288,12 +82078,12 @@ BEGIN SET vToday = CURDATE(); SET vTomorrowMidnight = TIMESTAMP(TIMESTAMPADD(DAY, 1, CURDATE()), '23:59:59'); - -- Riesgo + -- Riesgo CALL risk_vs_client_list(CURDATE()); - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT DISTINCT tt.Id_Ticket, 'RIESGO' + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'RIESGO', 1 FROM tmp.ticket_list tt JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket JOIN Agencias a on t.Id_Agencia = a.Id_Agencia @@ -79304,8 +82094,8 @@ BEGIN -- Congelado - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT DISTINCT tt.Id_Ticket, 'CONGELADO' + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'CONGELADO', 2 FROM tmp.ticket_list tt JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket JOIN Clientes c on c.Id_Cliente = t.Id_Cliente @@ -79313,27 +82103,13 @@ BEGIN -- Datos del cliente sin confirmar - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT DISTINCT tt.Id_Ticket, 'FICHA INCOMPLETA' + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'FICHA INCOMPLETA', 3 FROM tmp.ticket_list tt JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket JOIN Clientes c on c.Id_Cliente = t.Id_Cliente WHERE c.contabilizado = FALSE; - - - -- Tabla temporal para el cálculo del disponible - - DROP TEMPORARY TABLE IF EXISTS tmp.visible; - - CREATE TEMPORARY TABLE tmp.visible - (INDEX (itemFk,warehouseFk)) - SELECT `ish`.`itemFk` AS `itemFk`, SUM(`ish`.`visible`) AS `visible`, s.warehouseFk warehouseFk - 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` - GROUP BY itemFk,s.warehouseFk ; - + OPEN vCursor; l: LOOP @@ -79349,8 +82125,8 @@ BEGIN -- El disponible es menor que 0 - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT tt.Id_Ticket, Article + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, Article, 4 FROM tmp.ticket_list tt JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket LEFT JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket @@ -79368,14 +82144,15 @@ BEGIN AND vWarehouse = t.warehouse_id; -- El disponible es mayor que cero y la cantidad supera el visible, estando aun sin preparar - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT tt.Id_Ticket, CONCAT('RETRASO (', A.Id_Article, ') ', Article) + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, CONCAT('RETRASO (', A.Id_Article, ') ', Article), 5 FROM tmp.ticket_list tt JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket LEFT JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket LEFT JOIN `vn`.`saleTracking` `stPrevious` ON `stPrevious`.`saleFk` = M.Id_Movimiento - JOIN vn.state st ON st.id = `stPrevious`.`stateFk` + LEFT 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 @@ -79385,7 +82162,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 st.code = 'PREVIOUS_PREPARATION' AND M.Cantidad > IFNULL(v.visible,0) AND M.OK = FALSE AND stPrevious.saleFk IS NULL @@ -79399,37 +82176,46 @@ BEGIN -- 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) + /*DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingStock; + CREATE TEMPORARY TABLE tmp.itemShelvingStock + (INDEX (itemFk)) + SELECT itemFk ,visible + FROM vn.itemShelvingStock; +*/ + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT tt.Id_Ticket, CONCAT('ALT (', CAST(M.Cantidad AS DECIMAL(10,0)), ') ',M.Id_Article, ' ', Concepte),6 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 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' + LEFT JOIN vn.state st ON st.id = `stPrevious`.`stateFk` AND st.code = 'PREVIOUS_PREPARATION' JOIN cache.visible v ON M.Id_Article = v.item_id AND v.calc_id = vVisibleCache - JOIN tmp.visible visible ON visible.itemFk = v.item_id AND visible.warehouseFk = vWarehouse - WHERE v.visible - visible.visible < M.Cantidad + -- JOIN tmp.visible visible ON visible.itemFk = v.item_id AND visible.warehouseFk = vWarehouse + JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + -- WHERE v.visible - visible.visible < M.Cantidad + WHERE (v.visible - iss.visible) < M.Cantidad AND M.OK = FALSE AND stPrevious.saleFk IS NULL AND M.Reservado = FALSE AND CURDATE() = vDate AND tst.productionOrder < 6 - AND t.warehouse_id = vWarehouse ; + AND t.warehouse_id = vWarehouse; END LOOP; CLOSE vCursor; -- Código 100 - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT DISTINCT tt.Id_Ticket, 'COD 100' + INSERT INTO tmp.buffer_problems(Id_Ticket, problem, `order`) + SELECT DISTINCT tt.Id_Ticket, 'COD 100', 7 FROM tmp.ticket_list tt JOIN vn.ticketRequest tr on tr.ticketFk = tt.Id_Ticket WHERE tr.isOK IS NULL; - + + /*INSERT INTO tmp.buffer_problems(Id_Ticket, problem) SELECT DISTINCT tt.Id_Ticket, 'COD 100' FROM tmp.ticket_list tt @@ -79448,7 +82234,7 @@ BEGIN WHERE d.amount > 200 AND d.date = CURDATE() AND Vista != 3; -- para que las recogidas se preparen */ - DROP TEMPORARY TABLE tmp.visible; + -- DROP TEMPORARY TABLE tmp.visible; END ;; DELIMITER ; @@ -79476,6 +82262,217 @@ BEGIN 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 + , MINUTE(t.Fecha) as minuto + , t.Id_Ruta + , IF(a.Vista = 2,z.`id`,0) as zona + , CS.Consignatario + , CS.CODPOSTAL + , CS.POBLACION + , p.name PROVINCIA + , IF(a.Vista= 2, CONCAT(LEFT(z.`name`,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 + 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 vn.ticketState tls on tls.ticket = tt.Id_Ticket + LEFT JOIN Trabajadores w on w.Id_Trabajador = tls.worker + 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); + +ALTER TABLE tmp.production_buffer +CHANGE COLUMN `problem` `problem` VARCHAR(255); + -- 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; + + DELETE FROM tmp.production_buffer + WHERE `lines`= 0; + + -- Cajas + + 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 + + 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 + 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; + + -- Problemas por ticket + + UPDATE tmp.production_buffer pb + JOIN ( + SELECT Id_Ticket, COUNT(Id_Ticket) as problems, GROUP_CONCAT(problem ORDER BY `order`) 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 + + 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 + + CALL cache.departure_timing(vWarehouseId); + + -- 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; + + DROP TEMPORARY TABLE tmp.ticket_list; + DROP TEMPORARY TABLE IF EXISTS tmp.risk; +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 `production_control_source__` */; +/*!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 `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; + + 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)) @@ -82204,7 +85201,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 `salePreparingList` */; +/*!50003 DROP PROCEDURE IF EXISTS `salePreparingList__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -82214,7 +85211,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `salePreparingList`(IN idT BIGINT) +CREATE DEFINER=`root`@`%` PROCEDURE `salePreparingList__`(IN idT BIGINT) BEGIN SELECT t.clientFk, @@ -82258,6 +85255,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 `sale_comparative` */; +/*!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 `sale_comparative`( + v_date DATETIME + ,days TINYINT + ,i_wh TINYINT + ,i_tipo INT + ,i_filtro INT + ,vAvailableSinced DATE +) +BEGIN + DECLARE date_cyear_ini DATETIME; + DECLARE date_cyear_end DATETIME; + DECLARE week_count TINYINT DEFAULT 7; + DECLARE w1, w2, w3, w4, w5, w6, w7 INT; + DECLARE y1, y2, y3, y4, y5, y6, y7 INT; + DECLARE wperiod INT;-- DECLARE ws, ys INT; -- PAK 11/01/2016 + DECLARE i INT DEFAULT 0; + DECLARE strFILTRO VARCHAR(255) DEFAULT 'TRUE'; + + IF i_filtro THEN + SELECT `sql` INTO strFILTRO FROM filtros WHERE id = i_filtro; + END IF; + + IF days < 0 OR days > 60 THEN + SET days = 15; + END IF; + + IF i_wh = NULL THEN + SET i_wh = 0; + END IF; + -- JGF 2015-04-16 cambio -21 por -22 para que la semana cuente de domingo a sabado + SET date_cyear_ini = TIMESTAMP(DATE(TIMESTAMPADD(DAY, -22 - WEEKDAY(v_date), v_date)), '00:00:00'); + SET date_cyear_end = TIMESTAMP(DATE(TIMESTAMPADD(DAY, (7 * week_count) -1, date_cyear_ini)), '23:59:59'); + -- Eliminamos el calculo del inventario para fechas en el pasado + + DROP TEMPORARY TABLE IF EXISTS `article_inventory`; + CREATE TEMPORARY TABLE `article_inventory` + ( + `article_id` INT(11) NOT NULL PRIMARY KEY + ) + ENGINE = MEMORY; + + INSERT INTO article_inventory (article_id) + SELECT Id_Article FROM Articles a + JOIN Tipos t ON a.tipo_id = t.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = t.reino_id + WHERE (i_tipo = 0 OR a.tipo_id = i_tipo) + AND r.display <> 0; + + IF v_date < CURDATE() + THEN + ALTER TABLE `article_inventory` + ADD `buy_id` INT NOT NULL DEFAULT 0, + ADD `buy_date` DATE DEFAULT '2000-01-01', + ADD `life` INT DEFAULT 0, + ADD `sd` INT DEFAULT 0, + ADD `avalaible` INT DEFAULT 0, + ADD `visible` INT DEFAULT 0; + + ELSE + + CALL inventario_multiple_2 (vAvailableSinced, i_wh, days); + + CALL article_multiple_buy (v_date, i_wh); + + CALL article_multiple_buy_date (v_date, i_wh); + + + END IF; + + + DROP TEMPORARY TABLE IF EXISTS wtable; + + CREATE TEMPORARY TABLE wtable ( + cy INT(6), + ly INT(6) + ); + + REPEAT + SET i = i + 1; + SET wperiod = vnperiod(TIMESTAMPADD(DAY, 7*(i - 1), date_cyear_ini)); -- PAK 11/01/2016 + INSERT INTO wtable(cy, ly) VALUES(wperiod, wperiod - 100); -- VALUES( ys * 100 + ws, (ys -1) * 100 + ws); -- PAK 11/01/2016 + + UNTIL i = 7 END REPEAT; + + + SELECT cy, ly INTO w1, y1 FROM wtable limit 1; + SELECT cy, ly INTO w2, y2 FROM wtable WHERE cy > w1 limit 1; + SELECT cy, ly INTO w3, y3 FROM wtable WHERE cy > w2 limit 1; + SELECT cy, ly INTO w4, y4 FROM wtable WHERE cy > w3 limit 1; + + SELECT cy, ly INTO w5, y5 FROM wtable WHERE cy > w4 limit 1; + SELECT cy, ly INTO w6, y6 FROM wtable WHERE cy > w5 limit 1; + SELECT cy, ly INTO w7, y7 FROM wtable WHERE cy > w6 limit 1; + DROP TEMPORARY TABLE wtable; + + -- Genera una tabla con los datos del año pasado. + + DROP TEMPORARY TABLE IF EXISTS last_year; + CREATE TEMPORARY TABLE last_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(Periodo = y1, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek1 + ,CAST(SUM(IF(Periodo = y2, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek2 + ,CAST(SUM(IF(Periodo = y3, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek3 + ,CAST(SUM(IF(Periodo = y4, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek4 + ,CAST(SUM(IF(Periodo = y5, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek5 + ,CAST(SUM(IF(Periodo = y6, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek6 + ,CAST(SUM(IF(Periodo = y7, Cantidad, 0)) AS DECIMAL(10,0)) AS lweek7 + + ,CAST(SUM(IF(Periodo = y1, price, 0)) AS DECIMAL(10,0)) AS lprice1 + ,CAST(SUM(IF(Periodo = y2, price, 0)) AS DECIMAL(10,0)) AS lprice2 + ,CAST(SUM(IF(Periodo = y3, price, 0)) AS DECIMAL(10,0)) AS lprice3 + ,CAST(SUM(IF(Periodo = y4, price, 0)) AS DECIMAL(10,0)) AS lprice4 + ,CAST(SUM(IF(Periodo = y5, price, 0)) AS DECIMAL(10,0)) AS lprice5 + ,CAST(SUM(IF(Periodo = y6, price, 0)) AS DECIMAL(10,0)) AS lprice6 + ,CAST(SUM(IF(Periodo = y7, price, 0)) AS DECIMAL(10,0)) AS lprice7 + + FROM Comparativa + JOIN warehouse W on W.id = warehouse_id + WHERE (Periodo BETWEEN y1 and y7) + AND IF(i_wh = 0, W.is_comparative, i_wh = warehouse_id) + GROUP BY Id_Article; + + -- Genera una tabla con los datos de este año. + + DROP TEMPORARY TABLE IF EXISTS cur_year; + CREATE TEMPORARY TABLE cur_year + (KEY (Id_Article)) + ENGINE = MEMORY + SELECT Id_Article + + ,CAST(SUM(IF(week = w1, Total, 0)) AS DECIMAL(10,0)) AS cweek1 + ,CAST(SUM(IF(week = w2, Total, 0)) AS DECIMAL(10,0)) AS cweek2 + ,CAST(SUM(IF(week = w3, Total, 0)) AS DECIMAL(10,0)) AS cweek3 + ,CAST(SUM(IF(week = w4, Total, 0)) AS DECIMAL(10,0)) AS cweek4 + ,CAST(SUM(IF(week = w5, Total, 0)) AS DECIMAL(10,0)) AS cweek5 + ,CAST(SUM(IF(week = w6, Total, 0)) AS DECIMAL(10,0)) AS cweek6 + ,CAST(SUM(IF(week = w7, Total, 0)) AS DECIMAL(10,0)) AS cweek7 + + ,CAST(SUM(IF(week = w1, price, 0)) AS DECIMAL(10,0)) AS cprice1 + ,CAST(SUM(IF(week = w2, price, 0)) AS DECIMAL(10,0)) AS cprice2 + ,CAST(SUM(IF(week = w3, price, 0)) AS DECIMAL(10,0)) AS cprice3 + ,CAST(SUM(IF(week = w4, price, 0)) AS DECIMAL(10,0)) AS cprice4 + ,CAST(SUM(IF(week = w5, price, 0)) AS DECIMAL(10,0)) AS cprice5 + ,CAST(SUM(IF(week = w6, price, 0)) AS DECIMAL(10,0)) AS cprice6 + ,CAST(SUM(IF(week = w7, price, 0)) AS DECIMAL(10,0)) AS cprice7 + + FROM ( + SELECT A.Id_Article + ,CTS.period week + ,SUM(Cantidad) AS Total + ,TRUNCATE(SUM(Cantidad * IF(T.Fecha >= '2015-10-01',M.CostFixat,Preu * (100 - Descuento) / 100)),0) AS price + FROM Movimientos M + LEFT JOIN Tickets T ON T.Id_Ticket = M.Id_Ticket + INNER JOIN `time` CTS ON CTS.`date` = DATE(T.Fecha) + INNER JOIN Articles A USING (Id_Article) + INNER JOIN Tipos tp ON tp.tipo_id = A.tipo_id + LEFT JOIN reinos r ON r.id = tp.reino_id + JOIN warehouse W ON W.id = T.warehouse_id + WHERE Fecha BETWEEN date_cyear_ini AND date_cyear_end + AND T.Id_Cliente NOT IN(400,200) + AND IF(i_wh = 0, W.is_comparative, i_wh = T.warehouse_id) + AND r.display <> 0 + + GROUP BY A.Id_Article, week + ) t + GROUP BY Id_Article; + -- Genera la tabla con la comparativa. + + DROP TEMPORARY TABLE IF EXISTS remcom; + + SET strFILTRO = REPLACE(strFILTRO, 'Id_Article','A.Id_Article'); + SET strFILTRO = REPLACE(strFILTRO, 'tipo_id','tp.tipo_id'); + -- select * from article_inventory; + + DROP TEMPORARY TABLE IF EXISTS tmp.comparative; + + CALL util.exec (sql_printf + ( + 'CREATE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY + SELECT + an.nicho, p.name Productor, C.Packing, C.Costefijo, C.caja + ,A.Color, Id_Tipo as Tipo,A.tipo_id, o.Abreviatura as Origen, A.Categoria + ,A.Tallos, A.Medida, A.Article, TR.CodigoTrabajador + + ,cweek1, cweek2, cweek3, cweek4, cweek5, cweek6, cweek7 + ,lweek1, lweek2, lweek3, lweek4, lweek5, lweek6, lweek7 + + ,cprice1, cprice2, cprice3, cprice4, cprice5, cprice6, cprice7 + ,lprice1, lprice2, lprice3, lprice4, lprice5, lprice6, lprice7 + + ,A.Id_Article, i.buy_id , tp.life , CAST(IFNULL(i.sd,0) AS SIGNED) as sd + ,CAST(i.avalaible AS SIGNED) avalaible, CAST(i.visible AS SIGNED) visible, i.buy_date + ,E.Id_Proveedor AS provider_id + ,A.offer, A.bargain, A.comments, A.relevancy, A.description itemDescription + ,IF(cy.Id_Article IS NULL AND i.visible = 0 AND i.avalaible = 0 AND IFNULL(i.sd, 0) = 0, FALSE, TRUE) AS filtret + ,(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.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 + LEFT JOIN vn2008.Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = %s + LEFT JOIN vn2008.producer p ON p.producer_id = A.producer_id + LEFT JOIN vn2008.Tipos tp ON A.tipo_id = tp.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Trabajadores TR ON TR.Id_Trabajador = tp.Id_Trabajador + LEFT JOIN vn2008.Compres C ON i.buy_id = C.Id_Compra + LEFT JOIN vn2008.Entradas E USING(Id_Entrada) + LEFT JOIN vn2008.Origen o ON o.id = A.id_origen + LEFT JOIN vn2008.last_year ly ON ly.Id_Article = A.Id_Article + LEFT JOIN vn2008.cur_year cy ON cy.Id_Article = A.Id_Article AND (i.avalaible <> 0 OR i.visible <> 0 OR cweek1 OR cweek2 OR cweek3 OR cweek4 + OR cweek5 OR cweek6 OR cweek7 OR lweek1 OR lweek2 OR lweek3 OR lweek4 OR lweek5 + OR lweek6 OR lweek7) + WHERE r.display <> 0 AND %s ' + + ,i_wh,strFILTRO + )); + + -- Destruye las tablas temporales creadas. + + DROP TEMPORARY TABLE last_year; + DROP TEMPORARY TABLE cur_year; + DROP TEMPORARY TABLE article_inventory; +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 `scan_rutas_view` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -82538,7 +85778,7 @@ loop1: REPEAT Select @@global.innodb_open_files into @innodb_open_files; Select @@global.query_cache_size into @query_cache_size; Select @@global.query_cache_type into @query_cache_type; - + select @@global.log_output into @log_output; SELECT (Open_tables * Uptime / Opened_Tables) AS OpenTablesxUptimeDivOpened INTO @OpenTablesxUptimeDivOpened FROM (SELECT variable_value Uptime FROM information_schema.global_status @@ -82552,11 +85792,11 @@ loop1: REPEAT INSERT INTO sort_merge_results_ernesto (hora, uptime, uptime_since_flush, smp_old, smp_new, smp, smp_hour,connections, Threads_created, Threads_cached, Thread_cache_size, sort_buffer_size, opened_tables, Created_tmp_disk_tables, created_tmp_tables, Innodb_os_log_written, table_definition_cache, table_open_cache, table_open_cache_instances, open_tables, TABLE_OPEN_CACHE_OVERFLOWS, TABLE_OPEN_CACHE_MISSES, TABLE_OPEN_CACHE_HITS, tmp_table_size, max_heap_table_size, OpenTablesxUptimeDivOpened, join_buffer_size, open_files_limit, innodb_open_files, Created_tmp_files, query_cache_size, query_cache_type, Qcache_hits, - Qcache_inserts, Qcache_not_cached, Innodb_num_open_files, Open_table_definitions, read_rnd_buffer_size) + Qcache_inserts, Qcache_not_cached, Innodb_num_open_files, Open_table_definitions, read_rnd_buffer_size, log_output) VALUES (now(), @uptime, @uptime_since_flush, @SMP_OLD, @SMP_NEW, @SMP, @SMP_RATE, @connections, @Threads_created, @Threads_cached, @Thread_cache_size, @sort_buffer_size, @opened_tables, @Created_tmp_disk_tables, @created_tmp_tables, @Innodb_os_log_written, @table_definition_cache, @table_open_cache, @table_open_cache_instances, @open_tables, @TABLE_OPEN_CACHE_OVERFLOWS, @TABLE_OPEN_CACHE_MISSES, @TABLE_OPEN_CACHE_HITS, @tmp_table_size, @max_heap_table_size, @OpenTablesxUptimeDivOpened, @join_buffer_size, @open_files_limit, @innodb_open_files, @Created_tmp_files, @query_cache_size, @query_cache_type, @Qcache_hits, - @Qcache_inserts, @Qcache_not_cached, @Innodb_num_open_files, @Open_table_definitions, @read_rnd_buffer_size); + @Qcache_inserts, @Qcache_not_cached, @Innodb_num_open_files, @Open_table_definitions, @read_rnd_buffer_size, @log_output); if (i mod 3 = 0) then SELECT * FROM sort_merge_results_ernesto order by hora desc; @@ -85756,9 +88996,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -85834,7 +89074,7 @@ BEGIN WHERE tr.landing >= vDateFrom AND (wo.name="Colombia" OR wo.name="Ecuador") GROUP BY e.Id_Entrada ) sub - ORDER BY shipment, landing, travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ; + ORDER BY landing ASC, shipment ASC,travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ; END ;; DELIMITER ; @@ -87436,10 +90676,10 @@ CREATE TABLE `inter` ( KEY `inter_state` (`state_id`), KEY `inter_id` (`Id_Ticket`,`inter_id`) USING BTREE, CONSTRAINT `currante` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn2008`.`state` (`id`) ON UPDATE CASCADE, + CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=19607035 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20325798 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 */ ; @@ -88037,7 +91277,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_ventas` AS select (`bs`.`ventas`.`importe` * `vn2008`.`Movimientos`.`Cantidad`) AS `importe`,`bs`.`ventas`.`recargo` AS `recargo`,`vn2008`.`time`.`year` AS `year`,`vn2008`.`time`.`month` AS `month`,`vn2008`.`time`.`week` AS `week`,`vn2008`.`time`.`day` AS `day` from ((`bs`.`ventas` join `vn2008`.`time` on((`vn2008`.`time`.`date` = `bs`.`ventas`.`fecha`))) join `vn2008`.`Movimientos` on((`bs`.`ventas`.`Id_Movimiento` = `vn2008`.`Movimientos`.`Id_Movimiento`))) group by `vn2008`.`time`.`date` */; +/*!50001 VIEW `v_ventas` AS select (`bs`.`ventas`.`importe` * `Movimientos`.`Cantidad`) AS `importe`,`bs`.`ventas`.`recargo` AS `recargo`,`vn2008`.`time`.`year` AS `year`,`vn2008`.`time`.`month` AS `month`,`vn2008`.`time`.`week` AS `week`,`vn2008`.`time`.`day` AS `day` from ((`bs`.`ventas` join `vn2008`.`time` on((`vn2008`.`time`.`date` = `bs`.`ventas`.`fecha`))) join `vn2008`.`Movimientos` on((`bs`.`ventas`.`Id_Movimiento` = `Movimientos`.`Id_Movimiento`))) group by `vn2008`.`time`.`date` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88649,10 +91889,10 @@ USE `util`; USE `vn`; -- --- Final view structure for view `__addressObservation` +-- Final view structure for view `__taxClassCode` -- -/*!50001 DROP VIEW IF EXISTS `__addressObservation`*/; +/*!50001 DROP VIEW IF EXISTS `__taxClassCode`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -88661,16 +91901,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `__addressObservation` AS select `co`.`consignatarios_observation_id` AS `id`,`co`.`Id_Consigna` AS `addressFk`,`co`.`observation_type_id` AS `observationTypeFk`,`co`.`text` AS `description` from `vn2008`.`consignatarios_observation` `co` */; +/*!50001 VIEW `__taxClassCode` AS select `c`.`iva_group_id` AS `taxClassFk`,`c`.`date` AS `effectived`,`c`.`iva_codigo_id` AS `taxCodeFk` from `vn2008`.`iva_group_codigo` `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 `__clientCredit` +-- Final view structure for view `__taxCode` -- -/*!50001 DROP VIEW IF EXISTS `__clientCredit`*/; +/*!50001 DROP VIEW IF EXISTS `__taxCode`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -88679,61 +91919,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `__clientCredit` AS select `c`.`id` AS `id`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`amount` AS `amount`,`c`.`odbc_date` AS `created` from `vn2008`.`credit` `c` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `__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 VIEW `__taxCode` AS select `ic`.`id` AS `id`,`ic`.`fecha` AS `dated`,`ic`.`codigo` AS `code`,`ic`.`iva_tipo_id` AS `taxTypeFk`,`ic`.`iva` AS `rate`,`ic`.`recargo` AS `equalizationTax`,`ic`.`tipo` AS `type`,`ic`.`link` AS `link`,`ic`.`isActive` AS `isActive`,`ic`.`updated` AS `updated`,`ic`.`transactionCode` AS `transactionCode` from `vn2008`.`iva_codigo` `ic` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88793,37 +91979,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `agency` +-- Final view structure for view `addressObservation__` -- -/*!50001 DROP VIEW IF EXISTS `agency`*/; +/*!50001 DROP VIEW IF EXISTS `addressObservation__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `agency` AS select `a`.`agency_id` AS `id`,`a`.`name` AS `name`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`por_volumen` AS `isVolumetric`,`a`.`Id_Banco` AS `bankFk`,`a`.`warehouse_alias_id` AS `warehouseAliasFk`,`a`.`propios` AS `isOwn`,`a`.`zone_label` AS `labelZone`,`a`.`workCenterFk` AS `workCenterFk` from `vn2008`.`agency` `a` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `agencyMode` --- - -/*!50001 DROP VIEW IF EXISTS `agencyMode`*/; -/*!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 `agencyMode` AS select `a`.`Id_Agencia` AS `id`,`a`.`Agencia` AS `name`,`a`.`description` AS `description`,`a`.`Vista` AS `deliveryMethodFk`,`a`.`m3` AS `m3`,`a`.`cod71` AS `cod71`,`a`.`web` AS `web`,`a`.`agency_id` AS `agencyFk`,`a`.`agency_service_id` AS `agencyServiceFk`,`a`.`inflacion` AS `inflation`,`a`.`is_volumetric` AS `isVolumetric`,`a`.`send_mail` AS `reportMail`,`a`.`tpv` AS `isActive`,`a`.`code` AS `code` from `vn2008`.`Agencias` `a` */; +/*!50001 VIEW `addressObservation__` AS select `co`.`consignatarios_observation_id` AS `id`,`co`.`Id_Consigna` AS `addressFk`,`co`.`observation_type_id` AS `observationTypeFk`,`co`.`text` AS `description` from `vn2008`.`consignatarios_observation` `co` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88846,6 +92014,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `agencyMode__` +-- + +/*!50001 DROP VIEW IF EXISTS `agencyMode__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `agencyMode__` AS select `a`.`Id_Agencia` AS `id`,`a`.`Agencia` AS `name`,`a`.`description` AS `description`,`a`.`Vista` AS `deliveryMethodFk`,`a`.`m3` AS `m3`,`a`.`cod71` AS `cod71`,`a`.`web` AS `web`,`a`.`agency_id` AS `agencyFk`,`a`.`agency_service_id` AS `agencyServiceFk`,`a`.`inflacion` AS `inflation`,`a`.`is_volumetric` AS `isVolumetric`,`a`.`send_mail` AS `reportMail`,`a`.`tpv` AS `isActive`,`a`.`code` AS `code`,`a`.`show_AgencyName` AS `showAgencyName`,`a`.`externalAgency` AS `isExternalAgency`,`a`.`flag` AS `flag` from `vn2008`.`Agencias` `a` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `agencyProvince` -- @@ -88882,6 +92068,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `agency__` +-- + +/*!50001 DROP VIEW IF EXISTS `agency__`*/; +/*!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 `agency__` AS select `a`.`agency_id` AS `id`,`a`.`name` AS `name`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`por_volumen` AS `isVolumetric`,`a`.`Id_Banco` AS `bankFk`,`a`.`warehouse_alias_id` AS `warehouseAliasFk`,`a`.`propios` AS `isOwn`,`a`.`zone_label` AS `labelZone`,`a`.`workCenterFk` AS `workCenterFk` from `vn2008`.`agency` `a` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `annualAverageInvoiced` -- @@ -88918,24 +92122,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `bank` --- - -/*!50001 DROP VIEW IF EXISTS `bank`*/; -/*!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 `bank` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `cash`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive`,`b`.`currencyFk` AS `currencyFk` from `vn2008`.`Bancos` `b` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `bankEntity__` -- @@ -88954,6 +92140,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `bank__` +-- + +/*!50001 DROP VIEW IF EXISTS `bank__`*/; +/*!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 `bank__` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `cash`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive`,`b`.`currencyFk` AS `currencyFk` from `vn2008`.`Bancos` `b` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `botanicExport` -- @@ -88973,10 +92177,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `businessReasonEnd` +-- Final view structure for view `businessReasonEnd__` -- -/*!50001 DROP VIEW IF EXISTS `businessReasonEnd`*/; +/*!50001 DROP VIEW IF EXISTS `businessReasonEnd__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -88985,7 +92189,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `businessReasonEnd` AS select `b`.`id` AS `id`,`b`.`reason` AS `reason` from `vn2008`.`businessReasonEnd` `b` */; +/*!50001 VIEW `businessReasonEnd__` AS select `b`.`id` AS `id`,`b`.`reason` AS `reason` from `vn2008`.`businessReasonEnd` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89189,19 +92393,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `client` +-- Final view structure for view `clientCredit__` -- -/*!50001 DROP VIEW IF EXISTS `client`*/; +/*!50001 DROP VIEW IF EXISTS `clientCredit__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `client` AS select `c`.`id_cliente` AS `id`,`c`.`cliente` AS `name`,`c`.`if` AS `fi`,`c`.`razonSocial` AS `socialName`,`c`.`contacto` AS `contact`,`c`.`domicilio` AS `street`,`c`.`poblacion` AS `city`,`c`.`codPostal` AS `postcode`,`c`.`telefono` AS `phone`,`c`.`movil` AS `mobile`,`c`.`fax` AS `fax`,`c`.`real` AS `isRelevant`,`c`.`e-mail` AS `email`,`c`.`iban` AS `iban`,`c`.`vencimiento` AS `dueDay`,`c`.`Cuenta` AS `accountingAccount`,`c`.`RE` AS `isEqualizated`,`c`.`province_id` AS `provinceFk`,`c`.`invoice` AS `hasToInvoice`,`c`.`credito` AS `credit`,`c`.`Id_Pais` AS `countryFk`,`c`.`activo` AS `isActive`,`c`.`gestdoc_id` AS `gestdocFk`,`c`.`calidad` AS `quality`,`c`.`pay_met_id` AS `payMethodFk`,`c`.`created` AS `created`,`c`.`mail` AS `isToBeMailed`,`c`.`chanel_id` AS `contactChannelFk`,`c`.`sepaVnl` AS `hasSepaVnl`,`c`.`coreVnl` AS `hasCoreVnl`,`c`.`coreVnh` AS `hasCoreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`default_address` AS `defaultAddressFk`,`c`.`risk_calculated` AS `riskCalculated`,`c`.`clientes_tipo_id` AS `clientTypeFk`,`c`.`mail_address` AS `mailAddress`,`c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,`c`.`invoiceByAddress` AS `hasToInvoiceByAddress`,`c`.`contabilizado` AS `isTaxDataChecked`,`c`.`congelado` AS `isFreezed`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`Id_Trabajador` AS `salesPersonFk`,`c`.`vies` AS `isVies`,`c`.`EYPBC` AS `eypbc`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk` from `vn2008`.`Clientes` `c` */; +/*!50001 VIEW `clientCredit__` AS select `c`.`id` AS `id`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`amount` AS `amount`,`c`.`odbc_date` AS `created` from `vn2008`.`credit` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89225,10 +92429,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `clientDms` +-- Final view structure for view `clientDms__` -- -/*!50001 DROP VIEW IF EXISTS `clientDms`*/; +/*!50001 DROP VIEW IF EXISTS `clientDms__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89237,7 +92441,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientDms` AS select `g`.`Id_Cliente` AS `clientFk`,`g`.`gest_doc_id` AS `dmsFk` from `vn2008`.`clientes_gestdoc` `g` */; +/*!50001 VIEW `clientDms__` AS select `g`.`Id_Cliente` AS `clientFk`,`g`.`gest_doc_id` AS `dmsFk` from `vn2008`.`clientes_gestdoc` `g` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89261,19 +92465,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `clientObservation` +-- Final view structure for view `clientObservation__` -- -/*!50001 DROP VIEW IF EXISTS `clientObservation`*/; +/*!50001 DROP VIEW IF EXISTS `clientObservation__`*/; /*!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 `clientObservation` AS select `t`.`client_observation_id` AS `id`,`t`.`Id_Cliente` AS `clientFk`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`text` AS `text`,`t`.`odbc_date` AS `created` from `vn2008`.`client_observation` `t` */; +/*!50001 VIEW `clientObservation__` AS select `t`.`client_observation_id` AS `id`,`t`.`Id_Cliente` AS `clientFk`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`text` AS `text`,`t`.`odbc_date` AS `created` from `vn2008`.`client_observation` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89297,37 +92501,55 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `clientSample` +-- Final view structure for view `clientSample__` -- -/*!50001 DROP VIEW IF EXISTS `clientSample`*/; +/*!50001 DROP VIEW IF EXISTS `clientSample__`*/; /*!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 `clientSample` AS select `e`.`id` AS `id`,`e`.`Id_Cliente` AS `clientFk`,`e`.`escritos_id` AS `typeFk`,`e`.`fecha` AS `created`,`e`.`Id_Trabajador` AS `workerFk`,`e`.`userFk` AS `userFk`,`e`.`empresa_id` AS `companyFk` from `vn2008`.`escritos_det` `e` */; +/*!50001 VIEW `clientSample__` AS select `e`.`id` AS `id`,`e`.`Id_Cliente` AS `clientFk`,`e`.`escritos_id` AS `typeFk`,`e`.`fecha` AS `created`,`e`.`Id_Trabajador` AS `workerFk`,`e`.`userFk` AS `userFk`,`e`.`empresa_id` AS `companyFk`,`e`.`saldo` AS `balance` from `vn2008`.`escritos_det` `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 `clientType` +-- Final view structure for view `clientType__` -- -/*!50001 DROP VIEW IF EXISTS `clientType`*/; +/*!50001 DROP VIEW IF EXISTS `clientType__`*/; /*!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 `clientType` AS select `ct`.`clientes_tipo_id` AS `id`,`ct`.`code` AS `code`,`ct`.`tipo` AS `type`,`ct`.`isCreatedAsServed` AS `isCreatedAsServed` from `vn2008`.`clientes_tipo` `ct` */; +/*!50001 VIEW `clientType__` AS select `ct`.`clientes_tipo_id` AS `id`,`ct`.`code` AS `code`,`ct`.`tipo` AS `type`,`ct`.`isCreatedAsServed` AS `isCreatedAsServed` from `vn2008`.`clientes_tipo` `ct` */; +/*!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 `client__` +-- + +/*!50001 DROP VIEW IF EXISTS `client__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `client__` AS select `c`.`id_cliente` AS `id`,`c`.`cliente` AS `name`,`c`.`if` AS `fi`,`c`.`razonSocial` AS `socialName`,`c`.`contacto` AS `contact`,`c`.`domicilio` AS `street`,`c`.`poblacion` AS `city`,`c`.`codPostal` AS `postcode`,`c`.`telefono` AS `phone`,`c`.`movil` AS `mobile`,`c`.`fax` AS `fax`,`c`.`real` AS `isRelevant`,`c`.`e-mail` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`vencimiento` AS `dueDay`,`c`.`Cuenta` AS `accountingAccount`,`c`.`RE` AS `isEqualizated`,`c`.`province_id` AS `provinceFk`,`c`.`invoice` AS `hasToInvoice`,`c`.`credito` AS `credit`,`c`.`Id_Pais` AS `countryFk`,`c`.`activo` AS `isActive`,`c`.`gestdoc_id` AS `gestdocFk`,`c`.`calidad` AS `quality`,`c`.`pay_met_id` AS `payMethodFk`,`c`.`created` AS `created`,`c`.`mail` AS `isToBeMailed`,`c`.`chanel_id` AS `contactChannelFk`,`c`.`sepaVnl` AS `hasSepaVnl`,`c`.`coreVnl` AS `hasCoreVnl`,`c`.`coreVnh` AS `hasCoreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`default_address` AS `defaultAddressFk`,`c`.`risk_calculated` AS `riskCalculated`,`c`.`clientes_tipo_id` AS `clientTypeFk`,`c`.`mail_address` AS `mailAddress`,`c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,`c`.`invoiceByAddress` AS `hasToInvoiceByAddress`,`c`.`contabilizado` AS `isTaxDataChecked`,`c`.`congelado` AS `isFreezed`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`Id_Trabajador` AS `salesPersonFk`,`c`.`vies` AS `isVies`,`c`.`EYPBC` AS `eypbc`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk`,`c`.`recibo` AS `receipt`,`c`.`cc` AS `cc`,`c`.`descuento` AS `discount`,`c`.`oficial` AS `isOfficial`,`c`.`mayorista` AS `wholesaler`,`c`.`reexpedicion` AS `isReExpedition`,`c`.`notas` AS `notes`,`c`.`notas_administracion` AS `administrativeNotes`,`c`.`copiaFactura` AS `invoiceCopy`,`c`.`retener` AS `hold`,`c`.`cyc` AS `cyc`,`c`.`split_holland` AS `splitHolland`,`c`.`sepaFth` AS `sepaFth`,`c`.`coreFth` AS `coreFth`,`c`.`postcode_id` AS `postcodeOLD`,`c`.`codpos` AS `codposOLD` from `vn2008`.`Clientes` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89351,10 +92573,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `company` +-- Final view structure for view `company__` -- -/*!50001 DROP VIEW IF EXISTS `company`*/; +/*!50001 DROP VIEW IF EXISTS `company__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89363,7 +92585,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `company` AS select `e`.`id` AS `id`,`e`.`abbreviation` AS `code`,`e`.`Id_Proveedores_account` AS `supplierAccountFk`,`e`.`gerente_id` AS `workerManagerFk`,`e`.`digito_factura` AS `sage200Company`,`e`.`footnotes` AS `footnotes`,`e`.`phytosanitary` AS `phytosanitary`,`e`.`CodigoEmpresa` AS `companyCode`,`e`.`empresa_grupo` AS `companyGroupFk`,`e`.`morosidad` AS `isDefaulter`,`e`.`baja` AS `expired` from `vn2008`.`empresa` `e` */; +/*!50001 VIEW `company__` AS select `e`.`id` AS `id`,`e`.`abbreviation` AS `code`,`e`.`Id_Proveedores_account` AS `supplierAccountFk`,`e`.`gerente_id` AS `workerManagerFk`,`e`.`digito_factura` AS `sage200Company`,`e`.`footnotes` AS `footnotes`,`e`.`phytosanitary` AS `phytosanitary`,`e`.`CodigoEmpresa` AS `companyCode`,`e`.`empresa_grupo` AS `companyGroupFk`,`e`.`morosidad` AS `isDefaulter`,`e`.`baja` AS `expired` from `vn2008`.`empresa` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89513,10 +92735,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `country` +-- Final view structure for view `country__` -- -/*!50001 DROP VIEW IF EXISTS `country`*/; +/*!50001 DROP VIEW IF EXISTS `country__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89525,7 +92747,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `country` AS select `p`.`Id` AS `id`,`p`.`Pais` AS `country`,`p`.`CEE` AS `CEE`,`p`.`isUeeMember` AS `isUeeMember`,`p`.`Codigo` AS `code`,`p`.`Id_Moneda` AS `currencyFk`,`p`.`Id_Paisreal` AS `politicalCountryFk`,`p`.`geoFk` AS `geoFk`,`p`.`ibanLength` AS `ibanLength`,`p`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn2008`.`Paises` `p` */; +/*!50001 VIEW `country__` AS select `p`.`Id` AS `id`,`p`.`Pais` AS `country`,`p`.`CEE` AS `CEE`,`p`.`isUeeMember` AS `isUeeMember`,`p`.`Codigo` AS `code`,`p`.`Id_Moneda` AS `currencyFk`,`p`.`Id_Paisreal` AS `politicalCountryFk`,`p`.`geoFk` AS `geoFk`,`p`.`ibanLength` AS `ibanLength`,`p`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn2008`.`Paises` `p` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89567,10 +92789,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `deliveryMethod` +-- Final view structure for view `deliveryMethod__` -- -/*!50001 DROP VIEW IF EXISTS `deliveryMethod`*/; +/*!50001 DROP VIEW IF EXISTS `deliveryMethod__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89579,7 +92801,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `deliveryMethod` AS select `d`.`vista_id` AS `id`,`d`.`code` AS `code`,`d`.`vista` AS `description` from `vn2008`.`Vistas` `d` */; +/*!50001 VIEW `deliveryMethod__` AS select `d`.`vista_id` AS `id`,`d`.`code` AS `code`,`d`.`vista` AS `description` from `vn2008`.`Vistas` `d` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89621,37 +92843,37 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `deviceProduction` +-- Final view structure for view `deviceProductionUser__` -- -/*!50001 DROP VIEW IF EXISTS `deviceProduction`*/; +/*!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 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 `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 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 `deviceProductionUser` +-- Final view structure for view `deviceProduction__` -- -/*!50001 DROP VIEW IF EXISTS `deviceProductionUser`*/; +/*!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 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 `deviceProductionUser` AS select `d`.`device_id` AS `deviceProductionFk`,`d`.`user_id` AS `userFk` from `vn2008`.`device_user` `d` */; +/*!50001 VIEW `deviceProduction__` AS select `d`.`device_id` AS `id`,`d`.`sn` AS `imei`,`d`.`macWifi` AS `macWifi`,`d`.`departmentFk` AS `departmentFk`,`d`.`serialNumber` AS `serialNumber`,`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 */; @@ -89675,19 +92897,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `dmsType` +-- Final view structure for view `dmsType__` -- -/*!50001 DROP VIEW IF EXISTS `dmsType`*/; +/*!50001 DROP VIEW IF EXISTS `dmsType__`*/; /*!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 `dmsType` AS select `g`.`id` AS `id`,`g`.`tipo` AS `name`,`g`.`path` AS `path`,`g`.`readRoleFk` AS `readRoleFk`,`g`.`writeRoleFk` AS `writeRoleFk`,`g`.`code` AS `code` from `vn2008`.`gesttip` `g` */; +/*!50001 VIEW `dmsType__` AS select `g`.`id` AS `id`,`g`.`tipo` AS `name`,`g`.`path` AS `path`,`g`.`readRoleFk` AS `readRoleFk`,`g`.`writeRoleFk` AS `writeRoleFk`,`g`.`code` AS `code` from `vn2008`.`gesttip` `g` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89909,10 +93131,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `expedition` +-- Final view structure for view `expedition__` -- -/*!50001 DROP VIEW IF EXISTS `expedition`*/; +/*!50001 DROP VIEW IF EXISTS `expedition__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89921,16 +93143,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expedition` AS select `e`.`expeditions_id` AS `id`,`e`.`agency_id` AS `agencyModeFk`,`e`.`ticket_id` AS `ticketFk`,`e`.`EsBulto` AS `isBox`,`e`.`odbc_date` AS `created`,`e`.`Id_Article` AS `itemFk`,`e`.`counter` AS `counter`,`e`.`checked` AS `checked`,`e`.`workerFk` AS `workerFk`,`e`.`externalId` AS `externalId` from `vn2008`.`expeditions` `e` */; +/*!50001 VIEW `expedition__` AS select `e`.`expeditions_id` AS `id`,`e`.`agency_id` AS `agencyModeFk`,`e`.`ticket_id` AS `ticketFk`,`e`.`EsBulto` AS `isBox`,`e`.`odbc_date` AS `created`,`e`.`Id_Article` AS `itemFk`,`e`.`counter` AS `counter`,`e`.`checked` AS `checked`,`e`.`workerFk` AS `workerFk`,`e`.`externalId` AS `externalId` from `vn2008`.`expeditions` `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 `expence` +-- Final view structure for view `expence__` -- -/*!50001 DROP VIEW IF EXISTS `expence`*/; +/*!50001 DROP VIEW IF EXISTS `expence__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -89939,7 +93161,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `expence` AS select `g`.`Id_Gasto` AS `id`,`g`.`iva_tipo_id` AS `taxTypeFk`,`g`.`Gasto` AS `name`,`g`.`isWithheld` AS `isWithheld` from `vn2008`.`Gastos` `g` */; +/*!50001 VIEW `expence__` AS select `g`.`Id_Gasto` AS `id`,`g`.`iva_tipo_id` AS `taxTypeFk`,`g`.`Gasto` AS `name`,`g`.`isWithheld` AS `isWithheld` from `vn2008`.`Gastos` `g` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89957,7 +93179,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `vn`.`ticket` where (`ticket`.`shipped` > '2001-01-01') group by `ticket`.`clientFk` */; +/*!50001 VIEW `firstTicketShipped` AS select min(`ticket`.`shipped`) AS `shipped`,`ticket`.`clientFk` AS `clientFk` from `ticket` where (`ticket`.`shipped` > '2001-01-01') group by `ticket`.`clientFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89975,7 +93197,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`vn`.`buy` `b` join `vn`.`item` `i` on((`b`.`itemFk` = `i`.`id`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `vn`.`itemCategory` `ic` on((`ic`.`id` = `it`.`categoryFk`))) join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `vn`.`travel` `tr` on(((`tr`.`id` = `e`.`travelFk`) and (`ic`.`id` not in (8,6)) and (`b`.`buyingValue` <> 0) and (`b`.`quantity` <> 0) and (`e`.`supplierFk` in (1664,1665,1666,1465,1433))))) */; +/*!50001 VIEW `floraHollandBuyedItems` AS select `b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`b`.`quantity` AS `quantity`,`b`.`buyingValue` AS `buyingValue`,`tr`.`landed` AS `landed`,`e`.`companyFk` AS `companyFk` from (((((`buy` `b` join `item` `i` on((`b`.`itemFk` = `i`.`id`))) join `itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `itemCategory` `ic` on((`ic`.`id` = `it`.`categoryFk`))) join `entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `travel` `tr` on(((`tr`.`id` = `e`.`travelFk`) and (`ic`.`id` not in (8,6)) and (`b`.`buyingValue` <> 0) and (`b`.`quantity` <> 0) and (`e`.`supplierFk` in (1664,1665,1666,1465,1433))))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90124,24 +93346,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `ink` --- - -/*!50001 DROP VIEW IF EXISTS `ink`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `ink` AS select `c`.`Id_Tinta` AS `id`,`c`.`name` AS `name`,`c`.`Tinta` AS `picture`,`c`.`Orden` AS `showOrder` from `vn2008`.`Tintas` `c` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `inkL10n` -- @@ -90155,16 +93359,34 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`vn`.`ink` `k` left join `vn`.`inkI18n` `i` on(((`i`.`inkFk` = `k`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `inkL10n` AS select `k`.`id` AS `id`,ifnull(`i`.`name`,`k`.`name`) AS `name` from (`ink` `k` left join `inkI18n` `i` on(((`i`.`inkFk` = `k`.`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 */; -- --- Final view structure for view `intrastat` +-- Final view structure for view `ink__` -- -/*!50001 DROP VIEW IF EXISTS `intrastat`*/; +/*!50001 DROP VIEW IF EXISTS `ink__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ink__` AS select `c`.`Id_Tinta` AS `id`,`c`.`name` AS `name`,`c`.`Tinta` AS `picture`,`c`.`Orden` AS `showOrder`,`c`.`ball` AS `ball`,`c`.`cargex` AS `isCargex` from `vn2008`.`Tintas` `c` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `intrastat__` +-- + +/*!50001 DROP VIEW IF EXISTS `intrastat__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -90173,7 +93395,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `intrastat` AS select `i`.`Codintrastat` AS `id`,`i`.`Definicion` AS `description`,`i`.`iva_group_id` AS `taxClassFk`,`i`.`iva_codigo_id` AS `taxCodeFk` from `vn2008`.`Intrastat` `i` */; +/*!50001 VIEW `intrastat__` AS select `i`.`Codintrastat` AS `id`,`i`.`Definicion` AS `description`,`i`.`iva_group_id` AS `taxClassFk`,`i`.`iva_codigo_id` AS `taxCodeFk` from `vn2008`.`Intrastat` `i` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90209,7 +93431,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) */; +/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90323,10 +93545,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `invoiceOut` +-- Final view structure for view `invoiceOut__` -- -/*!50001 DROP VIEW IF EXISTS `invoiceOut`*/; +/*!50001 DROP VIEW IF EXISTS `invoiceOut__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -90335,61 +93557,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `invoiceOut` AS select `f`.`factura_id` AS `id`,`f`.`Id_Factura` AS `ref`,`f`.`Serie` AS `serial`,`f`.`Fecha` AS `issued`,`f`.`Importe` AS `amount`,`f`.`Id_Cliente` AS `clientFk`,`f`.`odbc_date` AS `created`,`f`.`empresa_id` AS `companyFk`,`f`.`Vencimiento` AS `dued`,`f`.`booked` AS `booked`,`f`.`Id_Banco` AS `bankFk`,`f`.`cplusInvoiceType477Fk` AS `cplusInvoiceType477Fk`,`f`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,`f`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,`f`.`cplusTrascendency477Fk` AS `cplusTrascendency477Fk`,`f`.`pdf` AS `hasPdf` from `vn2008`.`Facturas` `f` */; +/*!50001 VIEW `invoiceOut__` AS select `f`.`factura_id` AS `id`,`f`.`Id_Factura` AS `ref`,`f`.`Serie` AS `serial`,`f`.`Fecha` AS `issued`,`f`.`Importe` AS `amount`,`f`.`Id_Cliente` AS `clientFk`,`f`.`odbc_date` AS `created`,`f`.`empresa_id` AS `companyFk`,`f`.`Vencimiento` AS `dued`,`f`.`booked` AS `booked`,`f`.`Id_Banco` AS `bankFk`,`f`.`cplusInvoiceType477Fk` AS `cplusInvoiceType477Fk`,`f`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,`f`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,`f`.`cplusTrascendency477Fk` AS `cplusTrascendency477Fk`,`f`.`pdf` AS `hasPdf` from `vn2008`.`Facturas` `f` */; /*!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 `item` +-- Final view structure for view `itemBarcode__` -- -/*!50001 DROP VIEW IF EXISTS `item`*/; +/*!50001 DROP VIEW IF EXISTS `itemBarcode__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `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 */; - --- --- Final view structure for view `itemBarcode` --- - -/*!50001 DROP VIEW IF EXISTS `itemBarcode`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `itemBarcode` AS select `vn2008`.`barcodes`.`id` AS `id`,`vn2008`.`barcodes`.`Id_Article` AS `itemFk`,`vn2008`.`barcodes`.`code` AS `code` from `vn2008`.`barcodes` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `itemBotanical` --- - -/*!50001 DROP VIEW IF EXISTS `itemBotanical`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = 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 `itemBotanical` AS select `ab`.`Id_Article` AS `itemFk`,`ab`.`botanical` AS `botanical`,`ab`.`genus_id` AS `genusFk`,`ab`.`specie_id` AS `specieFk` from `vn2008`.`Articles_botanical` `ab` */; +/*!50001 VIEW `itemBarcode__` AS select `barcodes`.`id` AS `id`,`barcodes`.`Id_Article` AS `itemFk`,`barcodes`.`code` AS `code` from `vn2008`.`barcodes` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90412,6 +93598,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `itemBotanical__` +-- + +/*!50001 DROP VIEW IF EXISTS `itemBotanical__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `itemBotanical__` AS select `ab`.`Id_Article` AS `itemFk`,`ab`.`botanical` AS `botanical`,`ab`.`genus_id` AS `genusFk`,`ab`.`specie_id` AS `specieFk` from `vn2008`.`Articles_botanical` `ab` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `itemCategoryL10n` -- @@ -90431,19 +93635,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `itemPlacement` +-- Final view structure for view `itemCategory__` -- -/*!50001 DROP VIEW IF EXISTS `itemPlacement`*/; +/*!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 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 `itemPlacement` AS select `an`.`id` AS `id`,`an`.`Id_Article` AS `itemFk`,`an`.`warehouse_id` AS `warehouseFk`,`an`.`nicho` AS `code`,`an`.`reserve` AS `reserve`,`an`.`pickable` AS `pickable`,`an`.`modificationDate` AS `modificationDate` from `vn2008`.`Articles_nicho` `an` */; +/*!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 */; @@ -90461,25 +93665,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`,`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 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`,max(`p`.`code`) AS `parking`,max(`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__` +-- Final view structure for view `itemPlacement__` -- -/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +/*!50001 DROP VIEW IF EXISTS `itemPlacement__`*/; /*!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 `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 `itemPlacement__` AS select `an`.`id` AS `id`,`an`.`Id_Article` AS `itemFk`,`an`.`warehouse_id` AS `warehouseFk`,`an`.`nicho` AS `code`,`an`.`reserve` AS `reserve`,`an`.`pickable` AS `pickable`,`an`.`modificationDate` AS `modificationDate` from `vn2008`.`Articles_nicho` `an` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90497,7 +93701,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`,`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 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,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`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume` 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`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and (`stock`.`shelvingFk` <> 'FUE') 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 */; @@ -90515,7 +93719,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked` from (((`vn`.`itemShelving` `ish` join `vn`.`shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) order by `ish`.`created` */; +/*!50001 VIEW `itemShelvingList` AS select `ish`.`shelvingFk` AS `shelvingFk`,`ish`.`visible` AS `visible`,`ish`.`created` AS `created`,`pk`.`code` AS `parking`,`ish`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`parked` AS `parked` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) order by `ish`.`created` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90533,7 +93737,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`vn`.`itemShelving` `ish` join `vn`.`shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `vn`.`parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; +/*!50001 VIEW `itemShelvingPlacementSupplyStock` AS select `ish`.`id` AS `itemShelvingFk`,`ish`.`itemFk` AS `itemFk`,`ish`.`quantity` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`visible` AS `stock`,`i`.`longName` AS `longName`,`i`.`size` AS `size`,`i`.`subName` AS `subName`,`sh`.`code` AS `shelving`,`p`.`code` AS `parking`,`ish`.`created` AS `created`,ifnull(`sh`.`priority`,1) AS `priority` from (((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `itemShelvingSale` `iss` on((`iss`.`itemShelvingFk` = `ish`.`id`))) left join `itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90551,7 +93755,7 @@ USE `vn`; /*!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 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`,`p`.`sectorFk` AS `sectorFk` from (((`itemShelvingSale` `iss` join `itemShelving` `ish` on((`ish`.`id` = `iss`.`itemShelvingFk`))) join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) 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 */; @@ -90569,7 +93773,25 @@ 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`,`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 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) 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 `itemShelvingStockFull` +-- + +/*!50001 DROP VIEW IF EXISTS `itemShelvingStockFull`*/; +/*!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 `itemShelvingStockFull` AS select `ish`.`itemFk` AS `itemFk`,`ish`.`visible` AS `quantity`,`ish`.`packing` AS `packing`,`ish`.`grouping` AS `grouping`,`s`.`description` AS `sector`,`issr`.`removed` AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` 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`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90592,24 +93814,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `itemShelvingStock__` --- - -/*!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 */; -/*!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__` 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 */; - -- -- Final view structure for view `itemTagged` -- @@ -90664,6 +93868,42 @@ 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_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 `item__` +-- + +/*!50001 DROP VIEW IF EXISTS `item__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `item__` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`caja` AS `box`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown`,`t`.`compression` AS `compression`,`t`.`hasKgPrice` AS `hasKgPrice`,`t`.`Equivalente` AS `equivalent`,`t`.`Imprimir` AS `isToPrint`,`t`.`Albaranero` AS `isDeliveryNote`,`t`.`Familia` AS `family`,`t`.`do_photo` AS `doPhoto`,`t`.`Nicho` AS `niche`,`t`.`odbc_date` AS `created` from `vn2008`.`Articles` `t` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `mail` -- @@ -90737,28 +93977,28 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `orderTicket` +-- Final view structure for view `observationType__` -- -/*!50001 DROP VIEW IF EXISTS `orderTicket`*/; +/*!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 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 `orderTicket` AS select `b`.`order_id` AS `orderFk`,`b`.`Id_Ticket` AS `ticketFk` from `vn2008`.`order_Tickets` `b` */; +/*!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 `origin` +-- Final view structure for view `orderTicket__` -- -/*!50001 DROP VIEW IF EXISTS `origin`*/; +/*!50001 DROP VIEW IF EXISTS `orderTicket__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -90767,7 +94007,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `origin` AS select `o`.`id` AS `id`,`o`.`Abreviatura` AS `code`,`o`.`Origen` AS `name`,`o`.`Id_Paises` AS `countryFk` from `vn2008`.`Origen` `o` */; +/*!50001 VIEW `orderTicket__` AS select `b`.`order_id` AS `orderFk`,`b`.`Id_Ticket` AS `ticketFk` from `vn2008`.`order_Tickets` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90785,7 +94025,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`vn`.`origin` `o` left join `vn`.`originI18n` `i` on(((`i`.`originFk` = `o`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `originL10n` AS select `o`.`id` AS `id`,ifnull(`i`.`name`,`o`.`name`) AS `name` from (`origin` `o` left join `originI18n` `i` on(((`i`.`originFk` = `o`.`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 */; + +-- +-- Final view structure for view `origin__` +-- + +/*!50001 DROP VIEW IF EXISTS `origin__`*/; +/*!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 `origin__` AS select `o`.`id` AS `id`,`o`.`Abreviatura` AS `code`,`o`.`Origen` AS `name`,`o`.`Id_Paises` AS `countryFk` from `vn2008`.`Origen` `o` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90803,7 +94061,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `outgoingInvoiceKk` AS select `vn2008`.`Facturas`.`Id_Factura` AS `id`,`vn2008`.`Facturas`.`Serie` AS `serie`,`vn2008`.`Facturas`.`Fecha` AS `dateInvoice`,`vn2008`.`Facturas`.`Importe` AS `total`,`vn2008`.`Facturas`.`Vencimiento` AS `dueDate`,`vn2008`.`Facturas`.`Id_Banco` AS `bank`,`vn2008`.`Facturas`.`Id_Cliente` AS `client`,`vn2008`.`Facturas`.`Id_Remesa` AS `remittance`,`vn2008`.`Facturas`.`Remesar` AS `remit`,`vn2008`.`Facturas`.`Id_Trabajador` AS `worker`,`vn2008`.`Facturas`.`odbc_date` AS `creationDate`,`vn2008`.`Facturas`.`empresa_id` AS `company`,`vn2008`.`Facturas`.`liquidacion` AS `liquidacion?`,`vn2008`.`Facturas`.`pdf` AS `isPdf` from `vn2008`.`Facturas` */; +/*!50001 VIEW `outgoingInvoiceKk` AS select `Facturas`.`Id_Factura` AS `id`,`Facturas`.`Serie` AS `serie`,`Facturas`.`Fecha` AS `dateInvoice`,`Facturas`.`Importe` AS `total`,`Facturas`.`Vencimiento` AS `dueDate`,`Facturas`.`Id_Banco` AS `bank`,`Facturas`.`Id_Cliente` AS `client`,`Facturas`.`Id_Remesa` AS `remittance`,`Facturas`.`Remesar` AS `remit`,`Facturas`.`Id_Trabajador` AS `worker`,`Facturas`.`odbc_date` AS `creationDate`,`Facturas`.`empresa_id` AS `company`,`Facturas`.`liquidacion` AS `liquidacion?`,`Facturas`.`pdf` AS `isPdf` from `vn2008`.`Facturas` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90821,16 +94079,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `packageEquivalentItem` AS select `i`.`itemFk` AS `itemFk`,`ie`.`itemFk` AS `equivalentFk` from ((`vn`.`packageEquivalent` `pe` join `vn`.`packaging` `i` on((`i`.`id` = `pe`.`packageFk`))) join `vn`.`packaging` `ie` on((`ie`.`id` = `pe`.`equivalentFk`))) */; +/*!50001 VIEW `packageEquivalentItem` AS select `i`.`itemFk` AS `itemFk`,`ie`.`itemFk` AS `equivalentFk` from ((`packageEquivalent` `pe` join `packaging` `i` on((`i`.`id` = `pe`.`packageFk`))) join `packaging` `ie` on((`ie`.`id` = `pe`.`equivalentFk`))) */; /*!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 `packaging` +-- Final view structure for view `packaging__` -- -/*!50001 DROP VIEW IF EXISTS `packaging`*/; +/*!50001 DROP VIEW IF EXISTS `packaging__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -90839,16 +94097,16 @@ 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 `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 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 */; -- --- Final view structure for view `payDem` +-- Final view structure for view `payDem__` -- -/*!50001 DROP VIEW IF EXISTS `payDem`*/; +/*!50001 DROP VIEW IF EXISTS `payDem__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -90857,7 +94115,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `payDem` AS select `t`.`id` AS `id`,`t`.`pay_dem` AS `payDem` from `vn2008`.`pay_dem` `t` */; +/*!50001 VIEW `payDem__` AS select `t`.`id` AS `id`,`t`.`pay_dem` AS `payDem` from `vn2008`.`pay_dem` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91079,10 +94337,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `producer` +-- Final view structure for view `producer__` -- -/*!50001 DROP VIEW IF EXISTS `producer`*/; +/*!50001 DROP VIEW IF EXISTS `producer__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91091,7 +94349,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `producer` AS select `p`.`producer_id` AS `id`,`p`.`name` AS `name`,`p`.`visible` AS `isVisible` from `vn2008`.`producer` `p` */; +/*!50001 VIEW `producer__` AS select `p`.`producer_id` AS `id`,`p`.`name` AS `name`,`p`.`visible` AS `isVisible` from `vn2008`.`producer` `p` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91115,10 +94373,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `province` +-- Final view structure for view `province__` -- -/*!50001 DROP VIEW IF EXISTS `province`*/; +/*!50001 DROP VIEW IF EXISTS `province__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91127,16 +94385,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `province` AS select `t`.`province_id` AS `id`,`t`.`name` AS `name`,`t`.`Paises_Id` AS `countryFk`,`t`.`warehouse_id` AS `warehouseFk`,`t`.`zone` AS `zoneFk`,`t`.`geoFk` AS `geoFk` from `vn2008`.`province` `t` */; +/*!50001 VIEW `province__` AS select `t`.`province_id` AS `id`,`t`.`name` AS `name`,`t`.`Paises_Id` AS `countryFk`,`t`.`warehouse_id` AS `warehouseFk`,`t`.`zone` AS `zoneFk`,`t`.`geoFk` AS `geoFk` from `vn2008`.`province` `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 `queuePriority` +-- Final view structure for view `queuePriority__` -- -/*!50001 DROP VIEW IF EXISTS `queuePriority`*/; +/*!50001 DROP VIEW IF EXISTS `queuePriority__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91145,7 +94403,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `queuePriority` AS select `p`.`Id_Prioridad` AS `id`,`p`.`Prioridad` AS `priority` from `vn2008`.`Prioridades` `p` */; +/*!50001 VIEW `queuePriority__` AS select `p`.`Id_Prioridad` AS `id`,`p`.`Prioridad` AS `priority` from `vn2008`.`Prioridades` `p` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91187,10 +94445,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `recovery` +-- Final view structure for view `recovery__` -- -/*!50001 DROP VIEW IF EXISTS `recovery`*/; +/*!50001 DROP VIEW IF EXISTS `recovery__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91199,7 +94457,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `recovery` AS select `r`.`recovery_id` AS `id`,`r`.`Id_Cliente` AS `clientFk`,`r`.`dstart` AS `started`,`r`.`dend` AS `finished`,`r`.`amount` AS `amount`,`r`.`period` AS `period` from `vn2008`.`recovery` `r` */; +/*!50001 VIEW `recovery__` AS select `r`.`recovery_id` AS `id`,`r`.`Id_Cliente` AS `clientFk`,`r`.`dstart` AS `started`,`r`.`dend` AS `finished`,`r`.`amount` AS `amount`,`r`.`period` AS `period` from `vn2008`.`recovery` `r` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91241,10 +94499,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `route` +-- Final view structure for view `route__` -- -/*!50001 DROP VIEW IF EXISTS `route`*/; +/*!50001 DROP VIEW IF EXISTS `route__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91253,7 +94511,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `route` AS select `a`.`Id_Ruta` AS `id`,`a`.`Id_Trabajador` AS `workerFk`,`a`.`Fecha` AS `created`,`a`.`Id_Vehiculo` AS `vehicleFk`,`a`.`Id_Agencia` AS `agencyModeFk`,`a`.`Hora` AS `time`,`a`.`ok` AS `isOk`,`a`.`km_start` AS `kmStart`,`a`.`km_end` AS `kmEnd`,`a`.`date_start` AS `started`,`a`.`date_end` AS `finished`,`a`.`gestdoc_id` AS `gestdocFk`,`a`.`cost` AS `cost`,`a`.`m3` AS `m3`,`a`.`description` AS `description` from `vn2008`.`Rutas` `a` */; +/*!50001 VIEW `route__` AS select `a`.`Id_Ruta` AS `id`,`a`.`Id_Trabajador` AS `workerFk`,`a`.`Fecha` AS `created`,`a`.`Id_Vehiculo` AS `vehicleFk`,`a`.`Id_Agencia` AS `agencyModeFk`,`a`.`Hora` AS `time`,`a`.`ok` AS `isOk`,`a`.`km_start` AS `kmStart`,`a`.`km_end` AS `kmEnd`,`a`.`date_start` AS `started`,`a`.`date_end` AS `finished`,`a`.`gestdoc_id` AS `gestdocFk`,`a`.`cost` AS `cost`,`a`.`m3` AS `m3`,`a`.`description` AS `description` from `vn2008`.`Rutas` `a` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91277,10 +94535,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `sale` +-- Final view structure for view `saleChecked__` -- -/*!50001 DROP VIEW IF EXISTS `sale`*/; +/*!50001 DROP VIEW IF EXISTS `saleChecked__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91289,16 +94547,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sale` AS select `m`.`Id_Movimiento` AS `id`,`m`.`Id_Article` AS `itemFk`,`m`.`Id_Ticket` AS `ticketFk`,`m`.`Concepte` AS `concept`,`m`.`Cantidad` AS `quantity`,`m`.`Preu` AS `price`,`m`.`Descuento` AS `discount`,`m`.`Reservado` AS `reserved`,`m`.`OK` AS `isPicked`,`m`.`odbc_date` AS `created`,`m`.`CostFixat` AS `priceFixed`,`m`.`PrecioFijado` AS `isPriceFixed` from `vn2008`.`Movimientos` `m` */; +/*!50001 VIEW `saleChecked__` AS select `m`.`Id_Movimiento` AS `saleFk`,`m`.`checked` AS `isChecked` from `vn2008`.`Movimientos_checked` `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 `saleChecked` +-- Final view structure for view `saleComponent__` -- -/*!50001 DROP VIEW IF EXISTS `saleChecked`*/; +/*!50001 DROP VIEW IF EXISTS `saleComponent__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91307,25 +94565,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleChecked` AS select `m`.`Id_Movimiento` AS `saleFk`,`m`.`checked` AS `isChecked` from `vn2008`.`Movimientos_checked` `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 `saleComponent` --- - -/*!50001 DROP VIEW IF EXISTS `saleComponent`*/; -/*!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 `saleComponent` AS select `mc`.`Id_Movimiento` AS `saleFk`,`mc`.`Id_Componente` AS `componentFk`,`mc`.`Valor` AS `value`,`mc`.`created` AS `created` from `vn2008`.`Movimientos_componentes` `mc` */; +/*!50001 VIEW `saleComponent__` AS select `mc`.`Id_Movimiento` AS `saleFk`,`mc`.`Id_Componente` AS `componentFk`,`mc`.`Valor` AS `value`,`mc`.`created` AS `created` from `vn2008`.`Movimientos_componentes` `mc` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91349,10 +94589,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `saleTracking` +-- Final view structure for view `saleTracking__` -- -/*!50001 DROP VIEW IF EXISTS `saleTracking`*/; +/*!50001 DROP VIEW IF EXISTS `saleTracking__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91361,7 +94601,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleTracking` AS select `m`.`Id_Movimiento` AS `saleFk`,`m`.`valor` AS `isChecked`,`m`.`odbc_date` AS `created`,`m`.`original_quantity` AS `originalQuantity`,`m`.`Id_Trabajador` AS `workerFk`,`m`.`Id_Accion` AS `actionFk`,`m`.`Id_Movimiento_mark` AS `id`,`m`.`stateFk` AS `stateFk` from `vn2008`.`Movimientos_mark` `m` */; +/*!50001 VIEW `saleTracking__` AS select `m`.`Id_Movimiento` AS `saleFk`,`m`.`valor` AS `isChecked`,`m`.`odbc_date` AS `created`,`m`.`original_quantity` AS `originalQuantity`,`m`.`Id_Trabajador` AS `workerFk`,`m`.`Id_Accion` AS `actionFk`,`m`.`Id_Movimiento_mark` AS `id`,`m`.`stateFk` AS `stateFk` from `vn2008`.`Movimientos_mark` `m` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91379,16 +94619,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round((((`i`.`compression` * `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 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `r`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume` from (((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; /*!50001 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__` +-- Final view structure for view `sale__` -- -/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +/*!50001 DROP VIEW IF EXISTS `sale__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91396,8 +94636,26 @@ USE `vn`; /*!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`)))) */; +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sale__` AS select `m`.`Id_Movimiento` AS `id`,`m`.`Id_Article` AS `itemFk`,`m`.`Id_Ticket` AS `ticketFk`,`m`.`Concepte` AS `concept`,`m`.`Cantidad` AS `quantity`,`m`.`Preu` AS `price`,`m`.`Descuento` AS `discount`,`m`.`Reservado` AS `reserved`,`m`.`OK` AS `isPicked`,`m`.`odbc_date` AS `created`,`m`.`CostFixat` AS `priceFixed`,`m`.`PrecioFijado` AS `isPriceFixed` from `vn2008`.`Movimientos` `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 `salesToPrePrepare` +-- + +/*!50001 DROP VIEW IF EXISTS `salesToPrePrepare`*/; +/*!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 `salesToPrePrepare` 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`,`is`.`sectorFk` AS `sectorFk` 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') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91421,10 +94679,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `sharingCart` +-- Final view structure for view `sharingCart__` -- -/*!50001 DROP VIEW IF EXISTS `sharingCart`*/; +/*!50001 DROP VIEW IF EXISTS `sharingCart__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91433,16 +94691,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sharingCart` AS select `s`.`id` AS `id`,`s`.`Id_Trabajador` AS `workerFk`,`s`.`datSTART` AS `started`,`s`.`datEND` AS `ended`,`s`.`Id_Suplente` AS `workerSubstitute`,`s`.`odbc_date` AS `created` from `vn2008`.`sharingcart` `s` */; +/*!50001 VIEW `sharingCart__` AS select `s`.`id` AS `id`,`s`.`Id_Trabajador` AS `workerFk`,`s`.`datSTART` AS `started`,`s`.`datEND` AS `ended`,`s`.`Id_Suplente` AS `workerSubstitute`,`s`.`odbc_date` AS `created` from `vn2008`.`sharingcart` `s` */; /*!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 `sharingClient` +-- Final view structure for view `sharingClient__` -- -/*!50001 DROP VIEW IF EXISTS `sharingClient`*/; +/*!50001 DROP VIEW IF EXISTS `sharingClient__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91451,7 +94709,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `sharingClient` AS select `s`.`id` AS `id`,`s`.`Id_Trabajador` AS `workerFk`,`s`.`datSTART` AS `started`,`s`.`datEND` AS `ended`,`s`.`Id_Cliente` AS `clientFk` from `vn2008`.`sharingclient` `s` */; +/*!50001 VIEW `sharingClient__` AS select `s`.`id` AS `id`,`s`.`Id_Trabajador` AS `workerFk`,`s`.`datSTART` AS `started`,`s`.`datEND` AS `ended`,`s`.`Id_Cliente` AS `clientFk` from `vn2008`.`sharingclient` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91475,10 +94733,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `state` +-- Final view structure for view `state__` -- -/*!50001 DROP VIEW IF EXISTS `state`*/; +/*!50001 DROP VIEW IF EXISTS `state__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91487,43 +94745,25 @@ 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`,`s`.`isPreviousPreparable` AS `isPreviousPreparable` 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`,`s`.`isPicked` AS `isPicked` 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 */; -- --- Final view structure for view `supplier` +-- Final view structure for view `supplierAccount__` -- -/*!50001 DROP VIEW IF EXISTS `supplier`*/; +/*!50001 DROP VIEW IF EXISTS `supplierAccount__`*/; /*!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 `supplier` AS select `p`.`Id_Proveedor` AS `id`,`p`.`Proveedor` AS `name`,`p`.`cuenta` AS `account`,`p`.`pais_id` AS `countryFk`,`p`.`NIF` AS `nif`,`p`.`Agricola` AS `isFarmer`,`p`.`Telefono` AS `phone`,`p`.`cuentaret` AS `retAccount`,`p`.`ComisionProveedor` AS `commission`,`p`.`odbc_time` AS `created`,`p`.`postcode_id` AS `postcodeFk`,`p`.`active` AS `isActive`,`p`.`Domicilio` AS `street`,`p`.`Localidad` AS `city`,`p`.`province_id` AS `provinceFk`,`p`.`codpos` AS `postCode`,`p`.`pay_met_id` AS `payMethodFk`,`p`.`pay_dem_id` AS `payDemFk`,`p`.`Alias` AS `nickname` from `vn2008`.`Proveedores` `p` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `supplierAccount` --- - -/*!50001 DROP VIEW IF EXISTS `supplierAccount`*/; -/*!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 `supplierAccount` AS select `pa`.`Id_Proveedores_account` AS `id`,`pa`.`Id_Proveedor` AS `supplierFk`,`pa`.`IBAN` AS `iban`,`pa`.`entity_id` AS `bankEntityFk` from `vn2008`.`Proveedores_account` `pa` */; +/*!50001 VIEW `supplierAccount__` AS select `pa`.`Id_Proveedores_account` AS `id`,`pa`.`Id_Proveedor` AS `supplierFk`,`pa`.`IBAN` AS `iban`,`pa`.`entity_id` AS `bankEntityFk`,`pa`.`office` AS `office`,`pa`.`DC` AS `DC`,`pa`.`number` AS `number`,`pa`.`description` AS `description`,`pa`.`Id_Banco` AS `bankFk`,`pa`.`bic_sufix` AS `bicSufix` from `vn2008`.`Proveedores_account` `pa` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91546,6 +94786,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `supplier__` +-- + +/*!50001 DROP VIEW IF EXISTS `supplier__`*/; +/*!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 `supplier__` AS select `p`.`Id_Proveedor` AS `id`,`p`.`Proveedor` AS `name`,`p`.`cuenta` AS `account`,`p`.`pais_id` AS `countryFk`,`p`.`NIF` AS `nif`,`p`.`Agricola` AS `isFarmer`,`p`.`Telefono` AS `phone`,`p`.`cuentaret` AS `retAccount`,`p`.`ComisionProveedor` AS `commission`,`p`.`odbc_time` AS `created`,`p`.`postcode_id` AS `postcodeFk`,`p`.`active` AS `isActive`,`p`.`Domicilio` AS `street`,`p`.`Localidad` AS `city`,`p`.`province_id` AS `provinceFk`,`p`.`codpos` AS `postCode`,`p`.`pay_met_id` AS `payMethodFk`,`p`.`pay_dem_id` AS `payDemFk`,`p`.`Alias` AS `nickname` from `vn2008`.`Proveedores` `p` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `tagL10n` -- @@ -91565,10 +94823,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `taxClass` +-- Final view structure for view `taxClass__` -- -/*!50001 DROP VIEW IF EXISTS `taxClass`*/; +/*!50001 DROP VIEW IF EXISTS `taxClass__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91577,16 +94835,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `taxClass` AS select `c`.`iva_group_id` AS `id`,`c`.`description` AS `description`,`c`.`code` AS `code` from `vn2008`.`iva_group` `c` */; +/*!50001 VIEW `taxClass__` AS select `c`.`iva_group_id` AS `id`,`c`.`description` AS `description`,`c`.`code` AS `code` from `vn2008`.`iva_group` `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 `taxClassCode` +-- Final view structure for view `taxType__` -- -/*!50001 DROP VIEW IF EXISTS `taxClassCode`*/; +/*!50001 DROP VIEW IF EXISTS `taxType__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91595,61 +94853,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `taxClassCode` AS select `c`.`iva_group_id` AS `taxClassFk`,`c`.`date` AS `effectived`,`c`.`iva_codigo_id` AS `taxCodeFk` from `vn2008`.`iva_group_codigo` `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 `taxCode` --- - -/*!50001 DROP VIEW IF EXISTS `taxCode`*/; -/*!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 `taxCode` AS select `ic`.`id` AS `id`,`ic`.`fecha` AS `dated`,`ic`.`codigo` AS `code`,`ic`.`iva_tipo_id` AS `taxTypeFk`,`ic`.`iva` AS `rate`,`ic`.`recargo` AS `equalizationTax`,`ic`.`tipo` AS `type`,`ic`.`link` AS `link`,`ic`.`isActive` AS `isActive`,`ic`.`updated` AS `updated`,`ic`.`transactionCode` AS `transactionCode` from `vn2008`.`iva_codigo` `ic` */; -/*!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 `taxType` --- - -/*!50001 DROP VIEW IF EXISTS `taxType`*/; -/*!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 `taxType` AS select `t`.`id` AS `id`,`t`.`alias` AS `nickname`,`t`.`isAccrued` AS `isAccrued`,`t`.`serie_id` AS `serial`,`t`.`TIPOOPE` AS `TIPOOPE`,`t`.`descripcion` AS `description`,`t`.`Id_Pais` AS `countryFk` from `vn2008`.`iva_tipo` `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 `ticket` --- - -/*!50001 DROP VIEW IF EXISTS `ticket`*/; -/*!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 `ticket` AS select `t`.`Id_Ticket` AS `id`,`t`.`Id_Cliente` AS `clientFk`,`t`.`warehouse_id` AS `warehouseFk`,`t`.`Fecha` AS `shipped`,`t`.`landing` AS `landed`,`t`.`Alias` AS `nickname`,`t`.`Factura` AS `refFk`,`t`.`Id_Consigna` AS `addressFk`,`t`.`Localizacion` AS `location`,`t`.`Solucion` AS `solution`,`t`.`Id_Ruta` AS `routeFk`,`t`.`empresa_id` AS `companyFk`,`t`.`Id_Agencia` AS `agencyModeFk`,`t`.`Prioridad` AS `priority`,`t`.`Bultos` AS `packages`,`t`.`isDeleted` AS `isDeleted`,`t`.`odbc_date` AS `created`,`t`.`zoneFk` AS `zoneFk` from `vn2008`.`Tickets` `t` */; +/*!50001 VIEW `taxType__` AS select `t`.`id` AS `id`,`t`.`alias` AS `nickname`,`t`.`isAccrued` AS `isAccrued`,`t`.`serie_id` AS `serial`,`t`.`TIPOOPE` AS `TIPOOPE`,`t`.`descripcion` AS `description`,`t`.`Id_Pais` AS `countryFk` from `vn2008`.`iva_tipo` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91691,19 +94895,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `ticketGetVolume` +-- Final view structure for view `ticketGetVolume__` -- -/*!50001 DROP VIEW IF EXISTS `ticketGetVolume`*/; +/*!50001 DROP VIEW IF EXISTS `ticketGetVolume__`*/; /*!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 `ticketGetVolume` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`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 VIEW `ticketGetVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`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 */; @@ -91721,16 +94925,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum((((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)) as decimal(10,2)) AS `value` from (((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`company` `cm` on((`cm`.`id` = `t`.`companyFk`))) where (isnull(`t`.`refFk`) and (`t`.`shipped` > '2017-01-01')) group by `t`.`id` */; +/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum((((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)) as decimal(10,2)) AS `value` from (((`ticket` `t` join `sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `client` `c` on((`c`.`id` = `t`.`clientFk`))) join `company` `cm` on((`cm`.`id` = `t`.`companyFk`))) where (isnull(`t`.`refFk`) and (`t`.`shipped` > '2017-01-01')) group by `t`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `ticketObservation` +-- Final view structure for view `ticketObservation__` -- -/*!50001 DROP VIEW IF EXISTS `ticketObservation`*/; +/*!50001 DROP VIEW IF EXISTS `ticketObservation__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91739,16 +94943,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketObservation` AS select `to`.`ticket_observation_id` AS `id`,`to`.`Id_Ticket` AS `ticketFk`,`to`.`observation_type_id` AS `observationTypeFk`,`to`.`text` AS `description` from `vn2008`.`ticket_observation` `to` */; +/*!50001 VIEW `ticketObservation__` AS select `to`.`ticket_observation_id` AS `id`,`to`.`Id_Ticket` AS `ticketFk`,`to`.`observation_type_id` AS `observationTypeFk`,`to`.`text` AS `description` from `vn2008`.`ticket_observation` `to` */; /*!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 `ticketRequest` +-- Final view structure for view `ticketPreviousPreparingList` -- -/*!50001 DROP VIEW IF EXISTS `ticketRequest`*/; +/*!50001 DROP VIEW IF EXISTS `ticketPreviousPreparingList`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91757,7 +94961,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketRequest` AS select `t`.`Id_ORDEN` AS `id`,`t`.`ORDEN` AS `description`,`t`.`requesterFk` AS `requesterFk`,`t`.`atenderFk` AS `atenderFk`,`t`.`CANTIDAD` AS `quantity`,`t`.`Id_ARTICLE` AS `itemFk`,`t`.`PRECIOMAX` AS `price`,`t`.`isOk` AS `isOk`,`t`.`Id_Movimiento` AS `saleFk`,`t`.`ticketFk` AS `ticketFk`,`t`.`COMENTARIO` AS `response`,`t`.`odbc_date` AS `created` from `vn2008`.`Ordenes` `t` */; +/*!50001 VIEW `ticketPreviousPreparingList` AS select `t`.`id` AS `ticketFk`,`w`.`code` AS `code`,count(`st`.`id`) AS `saleLines`,sum((`st`.`isChecked` <> 0)) AS `alreadyMadeSaleLines`,(sum((`st`.`isChecked` <> 0)) / count(`st`.`id`)) AS `madeRate`,`st`.`created` AS `created`,`i`.`sectorFk` AS `sectorFk`,`p`.`code` AS `parking` from (((((((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`saleTracking` `st` on((`st`.`saleFk` = `s`.`id`))) join `vn`.`state` on((`vn`.`state`.`id` = `st`.`stateFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `st`.`workerFk`))) left join `vn`.`ticketParking` `tp` on((`tp`.`ticketFk` = `t`.`id`))) left join `vn`.`parking` `p` on((`p`.`id` = `tp`.`parkingFk`))) where (`vn`.`state`.`code` = 'PREVIOUS_PREPARATION') group by `s`.`ticketFk`,`i`.`sectorFk` */; +/*!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 `ticketRequest__` +-- + +/*!50001 DROP VIEW IF EXISTS `ticketRequest__`*/; +/*!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 `ticketRequest__` AS select `t`.`Id_ORDEN` AS `id`,`t`.`ORDEN` AS `description`,`t`.`requesterFk` AS `requesterFk`,`t`.`atenderFk` AS `atenderFk`,`t`.`CANTIDAD` AS `quantity`,`t`.`Id_ARTICLE` AS `itemFk`,`t`.`PRECIOMAX` AS `price`,`t`.`isOk` AS `isOk`,`t`.`Id_Movimiento` AS `saleFk`,`t`.`ticketFk` AS `ticketFk`,`t`.`COMENTARIO` AS `response`,`t`.`odbc_date` AS `created` from `vn2008`.`Ordenes` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91775,7 +94997,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`,`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 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`,`s`.`isPicked` AS `isPicked` 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 */; @@ -91793,7 +95015,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated`,`ts`.`isPicked` AS `isPicked` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91811,7 +95033,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketToPrepare` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,(`mk`.`original_quantity` - ifnull(`is`.`quantity`,0)) AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,if(hour(`t`.`shipped`),hour(`t`.`shipped`),hour(`z`.`hour`)) 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`.`zoneFk` AS `zoneFk` from (((((((`vn2008`.`Movimientos_mark` `mk` join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSale` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) where ((`mk`.`stateFk` = 26) and (`mk`.`valor` <> 1) and (`t`.`warehouseFk` = 1)) group by `mk`.`Id_Movimiento_mark` */; +/*!50001 VIEW `ticketToPrepare` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,(`mk`.`original_quantity` - ifnull(`is`.`quantity`,0)) AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,if(hour(`t`.`shipped`),hour(`t`.`shipped`),hour(`z`.`hour`)) 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`.`zoneFk` AS `zoneFk`,`p`.`sectorFk` AS `sectorFk` from ((((((((((`vn2008`.`Movimientos_mark` `mk` join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSale` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) left join `vn`.`itemShelving` `ish` on((`ish`.`id` = `is`.`itemShelvingFk`))) left join `vn`.`shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `vn`.`parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) where ((`mk`.`stateFk` = 26) and (`mk`.`valor` <> 1)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91835,10 +95057,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `ticketUpdateAction` +-- Final view structure for view `ticketUpdateAction__` -- -/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction`*/; +/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91847,16 +95069,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketUpdateAction` AS select `b`.`buo_id` AS `id`,`b`.`description` AS `description` from `vn2008`.`bionic_updating_options` `b` */; +/*!50001 VIEW `ticketUpdateAction__` AS select `b`.`buo_id` AS `id`,`b`.`description` AS `description` from `vn2008`.`bionic_updating_options` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `ticketWeekly` +-- Final view structure for view `ticketWeekly__` -- -/*!50001 DROP VIEW IF EXISTS `ticketWeekly`*/; +/*!50001 DROP VIEW IF EXISTS `ticketWeekly__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -91865,7 +95087,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketWeekly` AS select `t`.`Id_Ticket` AS `ticketFk`,`t`.`weekDay` AS `weekDay` from `vn2008`.`Tickets_turno` `t` */; +/*!50001 VIEW `ticketWeekly__` AS select `t`.`Id_Ticket` AS `ticketFk`,`t`.`weekDay` AS `weekDay` from `vn2008`.`Tickets_turno` `t` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `ticket__` +-- + +/*!50001 DROP VIEW IF EXISTS `ticket__`*/; +/*!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 `ticket__` AS select `t`.`Id_Ticket` AS `id`,`t`.`Id_Cliente` AS `clientFk`,`t`.`warehouse_id` AS `warehouseFk`,`t`.`Fecha` AS `shipped`,`t`.`landing` AS `landed`,`t`.`Alias` AS `nickname`,`t`.`Factura` AS `refFk`,`t`.`Id_Consigna` AS `addressFk`,`t`.`Localizacion` AS `location`,`t`.`Solucion` AS `solution`,`t`.`Id_Ruta` AS `routeFk`,`t`.`empresa_id` AS `companyFk`,`t`.`Id_Agencia` AS `agencyModeFk`,`t`.`Prioridad` AS `priority`,`t`.`Bultos` AS `packages`,`t`.`isDeleted` AS `isDeleted`,`t`.`odbc_date` AS `created`,`t`.`zoneFk` AS `zoneFk` from `vn2008`.`Tickets` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91883,7 +95123,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`.`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 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`,`is`.`sectorFk` AS `sectorFk` 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') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -92081,7 +95321,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`.`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 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`,`t`.`hasStowaway` AS `hasStowaway` 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 */; @@ -92189,7 +95429,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) */; +/*!50001 VIEW `workerLabour` AS select `b`.`business_id` AS `businessFk`,`p`.`id_trabajador` AS `workerFk`,`bl`.`workcenter_id` AS `workCenterFk`,`b`.`date_start` AS `started`,`b`.`date_end` AS `ended`,`d`.`id` AS `departmentFk` from ((((`postgresql`.`person` `p` join `postgresql`.`profile` `pr` on((`pr`.`person_id` = `p`.`person_id`))) join `postgresql`.`business` `b` on((`b`.`client_id` = `pr`.`profile_id`))) join `postgresql`.`business_labour` `bl` on((`b`.`business_id` = `bl`.`business_id`))) join `vn`.`department` `d` on((`d`.`id` = `bl`.`department_id`))) order by `b`.`date_start` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -92261,7 +95501,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,left(`t`.`dni`,8) AS `dni` from ((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) join `vn2008`.`Trabajadores` `t` on((`t`.`Id_Trabajador` = `w`.`id`))) */; +/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`u`.`bcryptPassword` AS `bcryptPassword`,`wd`.`departmentFk` AS `departmentFk`,left(`w`.`fi`,8) AS `dni` from ((`account`.`user` `u` join `vn`.`worker` `w` on((`w`.`userFk` = `u`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -92326,6 +95566,114 @@ USE `vn`; USE `vn2008`; +-- +-- Final view structure for view `Agencias` +-- + +/*!50001 DROP VIEW IF EXISTS `Agencias`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Agencias` AS select `am`.`id` AS `Id_Agencia`,`am`.`name` AS `Agencia`,`am`.`description` AS `description`,`am`.`deliveryMethodFk` AS `Vista`,`am`.`m3` AS `m3`,`am`.`cod71` AS `cod71`,`am`.`web` AS `web`,`am`.`agencyFk` AS `agency_id`,`am`.`agencyServiceFk` AS `agency_service_id`,`am`.`inflation` AS `inflacion`,`am`.`isVolumetric` AS `is_volumetric`,`am`.`reportMail` AS `send_mail`,`am`.`isActive` AS `tpv`,`am`.`code` AS `code`,`am`.`showAgencyName` AS `show_AgencyName`,`am`.`isExternalAgency` AS `externalAgency`,`am`.`flag` AS `flag` from `vn`.`agencyMode` `am` */; +/*!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 `Articles` +-- + +/*!50001 DROP VIEW IF EXISTS `Articles`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Articles` AS select `i`.`id` AS `Id_Article`,`i`.`name` AS `Article`,`i`.`typeFk` AS `tipo_id`,`i`.`size` AS `Medida`,`i`.`inkFk` AS `Color`,`i`.`category` AS `Categoria`,`i`.`stems` AS `Tallos`,`i`.`originFk` AS `id_origen`,`i`.`description` AS `description`,`i`.`producerFk` AS `producer_id`,`i`.`intrastatFk` AS `Codintrastat`,`i`.`isOnOffer` AS `offer`,`i`.`box` AS `caja`,`i`.`expenceFk` AS `expenceFk`,`i`.`isBargain` AS `bargain`,`i`.`comment` AS `comments`,`i`.`relevancy` AS `relevancy`,`i`.`image` AS `Foto`,`i`.`generic` AS `generic`,`i`.`density` AS `density`,`i`.`taxClassFk` AS `iva_group_id`,`i`.`minPrice` AS `PVP`,`i`.`hasMinPrice` AS `Min`,`i`.`isActive` AS `isActive`,`i`.`longName` AS `longName`,`i`.`subName` AS `subName`,`i`.`tag5` AS `tag5`,`i`.`value5` AS `value5`,`i`.`tag6` AS `tag6`,`i`.`value6` AS `value6`,`i`.`tag7` AS `tag7`,`i`.`value7` AS `value7`,`i`.`tag8` AS `tag8`,`i`.`value8` AS `value8`,`i`.`tag9` AS `tag9`,`i`.`value9` AS `value9`,`i`.`tag10` AS `tag10`,`i`.`value10` AS `value10`,`i`.`minimum` AS `minimum`,`i`.`upToDown` AS `upToDown`,`i`.`compression` AS `compression`,`i`.`hasKgPrice` AS `hasKgPrice`,`i`.`equivalent` AS `Equivalente`,`i`.`isToPrint` AS `Imprimir`,`i`.`isDeliveryNote` AS `Albaranero`,`i`.`family` AS `Familia`,`i`.`doPhoto` AS `do_photo`,`i`.`niche` AS `Nicho`,`i`.`created` AS `odbc_date` from `vn`.`item` `i` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Articles_botanical` +-- + +/*!50001 DROP VIEW IF EXISTS `Articles_botanical`*/; +/*!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 `Articles_botanical` AS select `ab`.`itemFk` AS `Id_Article`,`ab`.`botanical` AS `botanical`,`ab`.`genusFk` AS `genus_id`,`ab`.`specieFk` AS `specie_id` from `vn`.`itemBotanical` `ab` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Articles_nicho` +-- + +/*!50001 DROP VIEW IF EXISTS `Articles_nicho`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Articles_nicho` AS select `an`.`id` AS `id`,`an`.`itemFk` AS `Id_Article`,`an`.`warehouseFk` AS `warehouse_id`,`an`.`code` AS `nicho`,`an`.`reserve` AS `reserve`,`an`.`pickable` AS `pickable`,`an`.`modificationDate` AS `modificationDate` from `vn`.`itemPlacement` `an` */; +/*!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 `Bancos` +-- + +/*!50001 DROP VIEW IF EXISTS `Bancos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Bancos` AS select `b`.`id` AS `Id_Banco`,`b`.`bank` AS `Banco`,`b`.`account` AS `Cuenta`,`b`.`cash` AS `cash`,`b`.`entityFk` AS `entity_id`,`b`.`isActive` AS `activo`,`b`.`currencyFk` AS `currencyFk`,`b`.`warehouseFk` AS `warehouse_id` from `vn`.`bank` `b` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Clientes` +-- + +/*!50001 DROP VIEW IF EXISTS `Clientes`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Clientes` AS select `c`.`id` AS `id_cliente`,`c`.`name` AS `cliente`,`c`.`fi` AS `if`,`c`.`socialName` AS `razonSocial`,`c`.`contact` AS `contacto`,`c`.`street` AS `domicilio`,`c`.`city` AS `poblacion`,`c`.`postcode` AS `codPostal`,`c`.`phone` AS `telefono`,`c`.`mobile` AS `movil`,`c`.`fax` AS `fax`,`c`.`isRelevant` AS `real`,`c`.`email` AS `e-mail`,`c`.`iban` AS `iban`,`c`.`dueDay` AS `vencimiento`,`c`.`accountingAccount` AS `Cuenta`,`c`.`isEqualizated` AS `RE`,`c`.`provinceFk` AS `province_id`,`c`.`hasToInvoice` AS `invoice`,`c`.`credit` AS `credito`,`c`.`countryFk` AS `Id_Pais`,`c`.`isActive` AS `activo`,`c`.`gestdocFk` AS `gestdoc_id`,`c`.`quality` AS `calidad`,`c`.`payMethodFk` AS `pay_met_id`,`c`.`created` AS `created`,`c`.`isToBeMailed` AS `mail`,`c`.`contactChannelFk` AS `chanel_id`,`c`.`hasSepaVnl` AS `sepaVnl`,`c`.`hasCoreVnl` AS `coreVnl`,`c`.`hasCoreVnh` AS `coreVnh`,`c`.`hasLcr` AS `hasLcr`,`c`.`defaultAddressFk` AS `default_address`,`c`.`riskCalculated` AS `risk_calculated`,`c`.`clientTypeFk` AS `clientes_tipo_id`,`c`.`mailAddress` AS `mail_address`,`c`.`cplusTerIdNifFk` AS `cplusTerIdNifFk`,`c`.`hasToInvoiceByAddress` AS `invoiceByAddress`,`c`.`isTaxDataChecked` AS `contabilizado`,`c`.`isFreezed` AS `congelado`,`c`.`creditInsurance` AS `creditInsurance`,`c`.`isCreatedAsServed` AS `isCreatedAsServed`,`c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`,`c`.`salesPersonFk` AS `Id_Trabajador`,`c`.`isVies` AS `vies`,`c`.`eypbc` AS `EYPBC`,`c`.`bankEntityFk` AS `bankEntityFk`,`c`.`typeFk` AS `typeFk`,`c`.`receipt` AS `recibo`,`c`.`cc` AS `cc`,`c`.`discount` AS `descuento`,`c`.`isOfficial` AS `oficial`,`c`.`wholesaler` AS `mayorista`,`c`.`isReExpedition` AS `reexpedicion`,`c`.`notes` AS `notas`,`c`.`administrativeNotes` AS `notas_administracion`,`c`.`invoiceCopy` AS `copiaFactura`,`c`.`hold` AS `retener`,`c`.`cyc` AS `cyc`,`c`.`splitHolland` AS `split_holland`,`c`.`sepaFth` AS `sepaFth`,`c`.`coreFth` AS `coreFth`,`c`.`postcodeOld` AS `postcode_id`,`c`.`codposOLD` AS `codpos` from `vn`.`client` `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 `Compres` -- @@ -92344,6 +95692,42 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Compres_mark` +-- + +/*!50001 DROP VIEW IF EXISTS `Compres_mark`*/; +/*!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 `Compres_mark` AS select `bm`.`id` AS `Id_Compra`,`bm`.`comment` AS `comment`,`bm`.`mark` AS `mark`,`bm`.`odbcDate` AS `odbc_date` from `vn`.`buyMark` `bm` */; +/*!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 `Cubos` +-- + +/*!50001 DROP VIEW IF EXISTS `Cubos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Cubos` AS select `p`.`id` AS `Id_Cubo`,`p`.`volume` AS `Volumen`,`p`.`width` AS `X`,`p`.`depth` AS `Y`,`p`.`height` AS `Z`,`p`.`isPackageReturnable` AS `Retornable`,`p`.`created` AS `odbc_date`,`p`.`itemFk` AS `item_id`,`p`.`price` AS `pvp`,`p`.`cubicPackage` AS `bultoCubico`,`p`.`value` AS `Valor`,`p`.`packagingReturnFk` AS `idCubos_Retorno`,`p`.`lower` AS `Bajan`,`p`.`upload` AS `Suben`,`p`.`base` AS `Base`,`p`.`isBox` AS `box`,`p`.`returnCost` AS `costeRetorno` from `vn`.`packaging` `p` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `Entradas` -- @@ -92362,6 +95746,42 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Facturas` +-- + +/*!50001 DROP VIEW IF EXISTS `Facturas`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Facturas` AS select `io`.`id` AS `factura_id`,`io`.`ref` AS `Id_Factura`,`io`.`serial` AS `Serie`,`io`.`issued` AS `Fecha`,`io`.`amount` AS `Importe`,`io`.`clientFk` AS `Id_Cliente`,`io`.`created` AS `odbc_date`,`io`.`companyFk` AS `empresa_id`,`io`.`dued` AS `Vencimiento`,`io`.`booked` AS `booked`,`io`.`bankFk` AS `Id_Banco`,`io`.`cplusInvoiceType477Fk` AS `cplusInvoiceType477Fk`,`io`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,`io`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,`io`.`cplusTrascendency477Fk` AS `cplusTrascendency477Fk`,`io`.`hasPdf` AS `pdf`,`io`.`Id_Remesa__` AS `Id_Remesa`,`io`.`Remesar__` AS `Remesar`,`io`.`taxableBase7` AS `BI7`,`io`.`taxableBase16` AS `BI16`,`io`.`equ1` AS `RE1`,`io`.`equ4` AS `RE4`,`io`.`vat7` AS `IVA7`,`io`.`vat16` AS `IVA16`,`io`.`workerFk` AS `Id_Trabajador`,`io`.`liquidacion__` AS `liquidacion` from `vn`.`invoiceOut` `io` */; +/*!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 `Gastos` +-- + +/*!50001 DROP VIEW IF EXISTS `Gastos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Gastos` AS select `e`.`id` AS `Id_Gasto`,`e`.`taxTypeFk` AS `iva_tipo_id`,`e`.`name` AS `Gasto`,`e`.`isWithheld` AS `isWithheld`,`e`.`isConbase` AS `conbase`,`e`.`isForSale` AS `isForSale` from `vn`.`expence` `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 `Greuges` -- @@ -92398,6 +95818,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Intrastat` +-- + +/*!50001 DROP VIEW IF EXISTS `Intrastat`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Intrastat` AS select `i`.`id` AS `Codintrastat`,`i`.`description` AS `Definicion`,`i`.`taxClassFk` AS `iva_group_id`,`i`.`taxCodeFk` AS `iva_codigo_id`,`i`.`import` AS `import` from `vn`.`intrastat` `i` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `Monedas` -- @@ -92416,6 +95854,258 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Movimientos` +-- + +/*!50001 DROP VIEW IF EXISTS `Movimientos`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Movimientos` AS select `m`.`id` AS `Id_Movimiento`,`m`.`itemFk` AS `Id_Article`,`m`.`ticketFk` AS `Id_Ticket`,`m`.`concept` AS `Concepte`,`m`.`quantity` AS `Cantidad`,`m`.`price` AS `Preu`,`m`.`discount` AS `Descuento`,`m`.`reserved` AS `Reservado`,`m`.`isPicked` AS `OK`,`m`.`created` AS `odbc_date`,`m`.`priceFixed` AS `CostFixat`,`m`.`isPriceFixed` AS `PrecioFijado`,`m`.`originalQuantity` AS `quantity` from `vn`.`sale` `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 `Movimientos_checked` +-- + +/*!50001 DROP VIEW IF EXISTS `Movimientos_checked`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Movimientos_checked` AS select `sc`.`saleFk` AS `Id_Movimiento`,`sc`.`isChecked` AS `checked` from `vn`.`saleChecked` `sc` */; +/*!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 `Movimientos_componentes` +-- + +/*!50001 DROP VIEW IF EXISTS `Movimientos_componentes`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Movimientos_componentes` AS select `sc`.`saleFk` AS `Id_Movimiento`,`sc`.`componentFk` AS `Id_Componente`,`sc`.`value` AS `Valor`,`sc`.`created` AS `created`,`sc`.`isGreuge` AS `greuge` from `vn`.`saleComponent` `sc` */; +/*!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 `Movimientos_mark` +-- + +/*!50001 DROP VIEW IF EXISTS `Movimientos_mark`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Movimientos_mark` AS select `mm`.`saleFk` AS `Id_Movimiento`,`mm`.`isChecked` AS `valor`,`mm`.`created` AS `odbc_date`,`mm`.`originalQuantity` AS `original_quantity`,`mm`.`workerFk` AS `Id_Trabajador`,`mm`.`actionFk` AS `Id_Accion`,`mm`.`id` AS `Id_Movimiento_mark`,`mm`.`stateFk` AS `stateFk` from `vn`.`saleTracking` `mm` */; +/*!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 `Ordenes` +-- + +/*!50001 DROP VIEW IF EXISTS `Ordenes`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Ordenes` AS select `tr`.`id` AS `Id_ORDEN`,`tr`.`description` AS `ORDEN`,`tr`.`requesterFk` AS `requesterFk`,`tr`.`atenderFk` AS `atenderFk`,`tr`.`quantity` AS `CANTIDAD`,`tr`.`itemFk` AS `Id_ARTICLE`,`tr`.`price` AS `PRECIOMAX`,`tr`.`isOk` AS `isOk`,`tr`.`saleFk` AS `Id_Movimiento`,`tr`.`ticketFk` AS `ticketFk`,`tr`.`response` AS `COMENTARIO`,`tr`.`created` AS `odbc_date`,`tr`.`ordered` AS `datORDEN`,`tr`.`shipped` AS `datTICKET`,`tr`.`salesPersonCode` AS `CodVENDEDOR`,`tr`.`buyerCode` AS `CodCOMPRADOR`,`tr`.`price__` AS `PREU`,`tr`.`clientFk` AS `Id_CLIENTE`,`tr`.`ok__` AS `OK`,`tr`.`total` AS `TOTAL`,`tr`.`buyed` AS `datCOMPRA`,`tr`.`ko__` AS `KO` from `vn`.`ticketRequest` `tr` */; +/*!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 `Origen` +-- + +/*!50001 DROP VIEW IF EXISTS `Origen`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Origen` AS select `o`.`id` AS `id`,`o`.`code` AS `Abreviatura`,`o`.`name` AS `Origen`,`o`.`countryFk` AS `Id_Paises`,`o`.`warehouseFk` AS `warehouse_id`,`o`.`flag` AS `bandera`,`o`.`nl` AS `nl` from `vn`.`origin` `o` */; +/*!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 `Paises` +-- + +/*!50001 DROP VIEW IF EXISTS `Paises`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Paises` AS select `c`.`Id` AS `Id`,`c`.`country` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`politicalCountryFk` AS `Id_Paisreal`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice`,`c`.`nstGeoFk` AS `nst_geo_id`,`c`.`nstName` AS `nst_name` from `vn`.`country` `c` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Prioridades` +-- + +/*!50001 DROP VIEW IF EXISTS `Prioridades`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Prioridades` AS select `qp`.`id` AS `Id_Prioridad`,`qp`.`priority` AS `Prioridad` from `vn`.`queuePriority` `qp` */; +/*!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 `Proveedores` +-- + +/*!50001 DROP VIEW IF EXISTS `Proveedores`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`postCode__` AS `CP`,`s`.`isOfficial` AS `oficial`,`s`.`Fax` AS `Fax`,`s`.`payDay` AS `pay_day`,`s`.`isSerious` AS `serious`,`s`.`note` AS `notas` from `vn`.`supplier` `s` */; +/*!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 `Proveedores_account` +-- + +/*!50001 DROP VIEW IF EXISTS `Proveedores_account`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Proveedores_account` AS select `sa`.`id` AS `Id_Proveedores_account`,`sa`.`supplierFk` AS `Id_Proveedor`,`sa`.`iban` AS `IBAN`,`sa`.`bankEntityFk` AS `entity_id`,`sa`.`office` AS `office`,`sa`.`DC` AS `DC`,`sa`.`number` AS `number`,`sa`.`description` AS `description`,`sa`.`bankFk` AS `Id_Banco`,`sa`.`bicSufix` AS `bic_sufix` from `vn`.`supplierAccount` `sa` */; +/*!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 `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 = 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 `Rutas` AS select `r`.`id` AS `Id_Ruta`,`r`.`workerFk` AS `Id_Trabajador`,`r`.`created` AS `Fecha`,`r`.`vehicleFk` AS `Id_Vehiculo`,`r`.`agencyModeFk` AS `Id_Agencia`,`r`.`time` AS `Hora`,`r`.`isOk` AS `ok`,`r`.`kmStart` AS `km_start`,`r`.`kmEnd` AS `km_end`,`r`.`started` AS `date_start`,`r`.`finished` AS `date_end`,`r`.`gestdocFk` AS `gestdoc_id`,`r`.`cost` AS `cost`,`r`.`m3` AS `m3`,`r`.`description` AS `description` from `vn`.`route` `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 `Tickets` +-- + +/*!50001 DROP VIEW IF EXISTS `Tickets`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Tickets` AS select `t`.`id` AS `Id_Ticket`,`t`.`clientFk` AS `Id_Cliente`,`t`.`warehouseFk` AS `warehouse_id`,`t`.`shipped` AS `Fecha`,`t`.`landed` AS `landing`,`t`.`nickname` AS `Alias`,`t`.`refFk` AS `Factura`,`t`.`addressFk` AS `Id_Consigna`,`t`.`location` AS `Localizacion`,`t`.`solution` AS `Solucion`,`t`.`routeFk` AS `Id_Ruta`,`t`.`companyFk` AS `empresa_id`,`t`.`agencyModeFk` AS `Id_Agencia`,`t`.`priority` AS `Prioridad`,`t`.`packages` AS `Bultos`,`t`.`isDeleted` AS `isDeleted`,`t`.`created` AS `odbc_date`,`t`.`notes` AS `Notas`,`t`.`invoiceOutFk` AS `factura_id`,`t`.`isBooked` AS `Anotadoencaja`,`t`.`workerFk` AS `Id_Trabajador`,`t`.`observations` AS `Observaciones`,`t`.`isSigned` AS `Firmado`,`t`.`isLabeled` AS `Etiquetasemitidas`,`t`.`isPrinted` AS `PedidoImpreso`,`t`.`hour` AS `Hora`,`t`.`isBlocked` AS `blocked`,`t`.`hasPriority` AS `priority`,`t`.`isBoxed` AS `boxed`,`t`.`zoneFk` AS `zoneFk` from `vn`.`ticket` `t` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `Tickets_turno` +-- + +/*!50001 DROP VIEW IF EXISTS `Tickets_turno`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Tickets_turno` AS select `tw`.`ticketFk` AS `Id_Ticket`,`tw`.`weekDay` AS `weekDay` from `vn`.`ticketWeekly` `tw` */; +/*!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 `Tintas` +-- + +/*!50001 DROP VIEW IF EXISTS `Tintas`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Tintas` AS select `i`.`id` AS `Id_Tinta`,`i`.`name` AS `name`,`i`.`picture` AS `Tinta`,`i`.`showOrder` AS `Orden`,`i`.`ball` AS `ball`,`i`.`isCargex` AS `cargex` from `vn`.`ink` `i` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `Tipos` -- @@ -92470,6 +96160,42 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Vistas` +-- + +/*!50001 DROP VIEW IF EXISTS `Vistas`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `Vistas` AS select `dm`.`id` AS `vista_id`,`dm`.`code` AS `code`,`dm`.`description` AS `vista` from `vn`.`deliveryMethod` `dm` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `agency` +-- + +/*!50001 DROP VIEW IF EXISTS `agency`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `agency` AS select `a`.`id` AS `agency_id`,`a`.`name` AS `name`,`a`.`warehouseFk` AS `warehouse_id`,`a`.`isVolumetric` AS `por_volumen`,`a`.`bankFk` AS `Id_Banco`,`a`.`warehouseAliasFk` AS `warehouse_alias_id`,`a`.`isOwn` AS `propios`,`a`.`labelZone` AS `zone_label`,`a`.`workCenterFk` AS `workCenterFk` from `vn`.`agency` `a` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `awb_volume` -- @@ -92488,6 +96214,60 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `barcodes` +-- + +/*!50001 DROP VIEW IF EXISTS `barcodes`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `barcodes` AS select `b`.`id` AS `id`,`b`.`itemFk` AS `Id_Article`,`b`.`code` AS `code` from `vn`.`itemBarcode` `b` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `bionic_updating_options` +-- + +/*!50001 DROP VIEW IF EXISTS `bionic_updating_options`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `bionic_updating_options` AS select `t`.`id` AS `buo_id`,`t`.`description` AS `description` from `vn`.`ticketUpdateAction` `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 `businessReasonEnd` +-- + +/*!50001 DROP VIEW IF EXISTS `businessReasonEnd`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `businessReasonEnd` AS select `b`.`id` AS `id`,`b`.`reason` AS `reason` from `vn`.`businessReasonEnd` `b` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `buy_edi` -- @@ -92740,6 +96520,60 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `client_observation` +-- + +/*!50001 DROP VIEW IF EXISTS `client_observation`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `client_observation` AS select `co`.`id` AS `client_observation_id`,`co`.`clientFk` AS `Id_Cliente`,`co`.`workerFk` AS `Id_Trabajador`,`co`.`text` AS `text`,`co`.`created` AS `odbc_date` from `vn`.`clientObservation` `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 `clientes_gestdoc` +-- + +/*!50001 DROP VIEW IF EXISTS `clientes_gestdoc`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `clientes_gestdoc` AS select `cd`.`clientFk` AS `Id_Cliente`,`cd`.`dmsFk` AS `gest_doc_id` from `vn`.`clientDms` `cd` */; +/*!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 `clientes_tipo` +-- + +/*!50001 DROP VIEW IF EXISTS `clientes_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 = 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 `clientes_tipo` AS select `ct`.`id` AS `clientes_tipo_id`,`ct`.`code` AS `code`,`ct`.`type` AS `tipo`,`ct`.`isCreatedAsServed` AS `isCreatedAsServed` from `vn`.`clientType` `ct` */; +/*!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 `consignatarios_observation` -- @@ -92776,6 +96610,42 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `device` +-- + +/*!50001 DROP VIEW IF EXISTS `device`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `device` AS select `dp`.`id` AS `device_id`,`dp`.`imei` AS `sn`,`dp`.`macWifi` AS `macWifi`,`dp`.`serialNumber` AS `serialNumber`,`dp`.`departmentFk` AS `departmentFk`,`dp`.`modelFk` AS `model`,`dp`.`isOutOfService` AS `isOutOfService` from `vn`.`deviceProduction` `dp` */; +/*!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 `device_user` +-- + +/*!50001 DROP VIEW IF EXISTS `device_user`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `device_user` AS select `dpu`.`deviceProductionFk` AS `device_id`,`dpu`.`userFk` AS `user_id` from `vn`.`deviceProductionUser` `dpu` */; +/*!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 `edi_article` -- @@ -92974,6 +96844,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `empresa` +-- + +/*!50001 DROP VIEW IF EXISTS `empresa`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `empresa` AS select `c`.`id` AS `id`,`c`.`code` AS `abbreviation`,`c`.`supplierAccountFk` AS `Id_Proveedores_account`,`c`.`workerManagerFk` AS `gerente_id`,`c`.`sage200Company` AS `digito_factura`,`c`.`footnotes` AS `footnotes`,`c`.`phytosanitary` AS `phytosanitary`,`c`.`companyCode` AS `CodigoEmpresa`,`c`.`companyGroupFk` AS `empresa_grupo`,`c`.`isDefaulter` AS `morosidad`,`c`.`expired` AS `baja`,`c`.`register` AS `registro`,`c`.`registered` AS `alta`,`c`.`logo` AS `logo`,`c`.`isOfficial` AS `oficial`,`c`.`hasCyc` AS `cyc`,`c`.`rgb` AS `rgb`,`c`.`email` AS `mail`,`c`.`stamp` AS `cuno`,`c`.`created` AS `ODBC_DATE`,`c`.`clientFk` AS `Id_Cliente` from `vn`.`company` `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 `empresa_grupo` -- @@ -93010,6 +96898,60 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `escritos_det` +-- + +/*!50001 DROP VIEW IF EXISTS `escritos_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 = 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 `escritos_det` AS select `cs`.`id` AS `id`,`cs`.`clientFk` AS `Id_Cliente`,`cs`.`typeFk` AS `escritos_id`,`cs`.`created` AS `fecha`,`cs`.`workerFk` AS `Id_Trabajador`,`cs`.`userFk` AS `userFk`,`cs`.`companyFk` AS `empresa_id`,`cs`.`balance` AS `saldo` from `vn`.`clientSample` `cs` */; +/*!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 `expeditions` +-- + +/*!50001 DROP VIEW IF EXISTS `expeditions`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditions` AS select `e`.`id` AS `expeditions_id`,`e`.`agencyModeFk` AS `agency_id`,`e`.`ticketFk` AS `ticket_id`,`e`.`isBox` AS `EsBulto`,`e`.`created` AS `odbc_date`,`e`.`itemFk` AS `Id_Article`,`e`.`counter` AS `counter`,`e`.`checked` AS `checked`,`e`.`workerFk` AS `workerFk`,`e`.`externalId` AS `externalId`,`e`.`isRefund` AS `reembolso`,`e`.`isPickUp` AS `recogida` from `vn`.`expedition` `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 `gesttip` +-- + +/*!50001 DROP VIEW IF EXISTS `gesttip`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `gesttip` AS select `g`.`id` AS `id`,`g`.`name` AS `tipo`,`g`.`path` AS `path`,`g`.`readRoleFk` AS `readRoleFk`,`g`.`writeRoleFk` AS `writeRoleFk`,`g`.`code` AS `code` from `vn`.`dmsType` `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 `itemTag` -- @@ -93041,7 +96983,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item_entry_in` AS select `t`.`warehouse_id` AS `warehouse_id`,`t`.`landing` AS `dat`,`m`.`Id_Article` AS `item_id`,`m`.`Cantidad` AS `amount`,`t`.`received` AS `received`,`e`.`Redada` AS `isVirtualStock` from ((`vn2008`.`Compres` `m` join `vn2008`.`Entradas` `e` on((`m`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `t` on((`e`.`travel_id` = `t`.`id`))) where ((`e`.`Inventario` = 0) and (`m`.`Cantidad` <> 0)) */; +/*!50001 VIEW `item_entry_in` AS select `t`.`warehouse_id` AS `warehouse_id`,`t`.`landing` AS `dat`,`m`.`Id_Article` AS `item_id`,`m`.`Cantidad` AS `amount`,`t`.`received` AS `received`,`e`.`Redada` AS `isVirtualStock`,`e`.`Id_Entrada` AS `entryFk` from ((`vn2008`.`Compres` `m` join `vn2008`.`Entradas` `e` on((`m`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `t` on((`e`.`travel_id` = `t`.`id`))) where ((`e`.`Inventario` = 0) and (`m`.`Cantidad` <> 0)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93059,7 +97001,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item_entry_out` AS select `t`.`warehouse_id_out` AS `warehouse_id`,`t`.`shipment` AS `dat`,`m`.`Id_Article` AS `item_id`,-(`m`.`Cantidad`) AS `amount`,(`t`.`delivered` or ifnull(`co`.`valor`,0)) AS `delivered` from (((`vn2008`.`Compres` `m` join `vn2008`.`Entradas` `e` on((`m`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `t` on((`e`.`travel_id` = `t`.`id`))) left join `vn2008`.`Compres_ok` `co` on(((`co`.`Id_Compra` = `m`.`Id_Compra`) and (`co`.`Id_Accion` = 3) and (`co`.`valor` <> 0)))) where ((`e`.`Inventario` = 0) and (`e`.`Redada` = 0) and (`m`.`Cantidad` <> 0)) */; +/*!50001 VIEW `item_entry_out` AS select `t`.`warehouse_id_out` AS `warehouse_id`,`t`.`shipment` AS `dat`,`m`.`Id_Article` AS `item_id`,-(`m`.`Cantidad`) AS `amount`,(`t`.`delivered` or ifnull(`co`.`valor`,0)) AS `delivered`,`e`.`Id_Entrada` AS `entryFk` from (((`vn2008`.`Compres` `m` join `vn2008`.`Entradas` `e` on((`m`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `t` on((`e`.`travel_id` = `t`.`id`))) left join `vn2008`.`Compres_ok` `co` on(((`co`.`Id_Compra` = `m`.`Id_Compra`) and (`co`.`Id_Accion` = 3) and (`co`.`valor` <> 0)))) where ((`e`.`Inventario` = 0) and (`e`.`Redada` = 0) and (`m`.`Cantidad` <> 0)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93077,7 +97019,79 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item_out` AS select `t`.`warehouse_id` AS `warehouse_id`,`t`.`Fecha` AS `dat`,`m`.`Id_Article` AS `item_id`,-(`m`.`Cantidad`) AS `amount`,`m`.`OK` AS `ok`,`m`.`Reservado` AS `Reservado`,`t`.`Factura` AS `invoice`,`m`.`Id_Movimiento` AS `saleFk`,`m`.`Id_Ticket` AS `ticketFk` from (`Movimientos` `m` join `Tickets` `t` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) where (`m`.`Cantidad` <> 0) */; +/*!50001 VIEW `item_out` AS select `t`.`warehouse_id` AS `warehouse_id`,`t`.`Fecha` AS `dat`,`m`.`Id_Article` AS `item_id`,-(`m`.`Cantidad`) AS `amount`,`m`.`OK` AS `ok`,`m`.`Reservado` AS `Reservado`,`t`.`Factura` AS `invoice`,`m`.`Id_Movimiento` AS `saleFk`,`m`.`Id_Ticket` AS `ticketFk` from (`vn2008`.`Movimientos` `m` join `vn2008`.`Tickets` `t` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) where (`m`.`Cantidad` <> 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 `iva_codigo` +-- + +/*!50001 DROP VIEW IF EXISTS `iva_codigo`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `iva_codigo` AS select `tc`.`id` AS `id`,`tc`.`dated` AS `fecha`,`tc`.`code` AS `codigo`,`tc`.`taxTypeFk` AS `iva_tipo_id`,`tc`.`rate` AS `iva`,`tc`.`equalizationTax` AS `recargo`,`tc`.`type` AS `tipo`,`tc`.`link` AS `link`,`tc`.`isActive` AS `isActive`,`tc`.`updated` AS `updated`,`tc`.`transactionCode` AS `transactionCode` from `vn`.`taxCode` `tc` */; +/*!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 `iva_group` +-- + +/*!50001 DROP VIEW IF EXISTS `iva_group`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `iva_group` AS select `tc`.`id` AS `iva_group_id`,`tc`.`description` AS `description`,`tc`.`code` AS `code` from `vn`.`taxClass` `tc` */; +/*!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 `iva_group_codigo` +-- + +/*!50001 DROP VIEW IF EXISTS `iva_group_codigo`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `iva_group_codigo` AS select `tcc`.`taxClassFk` AS `iva_group_id`,`tcc`.`effectived` AS `date`,`tcc`.`taxCodeFk` AS `iva_codigo_id` from `vn`.`taxClassCode` `tcc` */; +/*!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 `iva_tipo` +-- + +/*!50001 DROP VIEW IF EXISTS `iva_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 = 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 `iva_tipo` AS select `tt`.`id` AS `id`,`tt`.`nickname` AS `alias`,`tt`.`isAccrued` AS `isAccrued`,`tt`.`serial` AS `serie_id`,`tt`.`TIPOOPE` AS `TIPOOPE`,`tt`.`description` AS `descripcion`,`tt`.`countryFk` AS `Id_Pais` from `vn`.`taxType` `tt` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93095,7 +97109,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `manaByTicket` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Fecha` AS `Fecha`,`cs`.`Id_cliente` AS `Id_Cliente`,(`m`.`Cantidad` * `mc`.`Valor`) AS `mana` from (((`Tickets` `t` join `Consignatarios` `cs` on((`t`.`Id_Consigna` = `cs`.`id_consigna`))) join `Movimientos` `m` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) join `Movimientos_componentes` `mc` on((`mc`.`Id_Movimiento` = `m`.`Id_Movimiento`))) where ((`mc`.`Id_Componente` in (37,39)) and (`t`.`Fecha` between '2016-01-01' and curdate())) */; +/*!50001 VIEW `manaByTicket` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Fecha` AS `Fecha`,`cs`.`Id_cliente` AS `Id_Cliente`,(`m`.`Cantidad` * `mc`.`Valor`) AS `mana` from (((`vn2008`.`Tickets` `t` join `vn2008`.`Consignatarios` `cs` on((`t`.`Id_Consigna` = `cs`.`id_consigna`))) join `vn2008`.`Movimientos` `m` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) join `vn2008`.`Movimientos_componentes` `mc` on((`mc`.`Id_Movimiento` = `m`.`Id_Movimiento`))) where ((`mc`.`Id_Componente` in (37,39)) and (`t`.`Fecha` between '2016-01-01' and curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93172,6 +97186,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `order_Tickets` +-- + +/*!50001 DROP VIEW IF EXISTS `order_Tickets`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `order_Tickets` AS select `ot`.`orderFk` AS `order_id`,`ot`.`ticketFk` AS `Id_Ticket` from `vn`.`orderTicket` `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 `order_component` -- @@ -93208,6 +97240,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `pay_dem` +-- + +/*!50001 DROP VIEW IF EXISTS `pay_dem`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `pay_dem` AS select `pd`.`id` AS `id`,`pd`.`payDem` AS `pay_dem` from `vn`.`payDem` `pd` */; +/*!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 `person_user` -- @@ -93244,6 +97294,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `producer` +-- + +/*!50001 DROP VIEW IF EXISTS `producer`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `producer` AS select `p`.`id` AS `producer_id`,`p`.`name` AS `name`,`p`.`isVisible` AS `visible` from `vn`.`producer` `p` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `proveedores_clientes` -- @@ -93257,7 +97325,43 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `proveedores_clientes` AS select `Proveedores`.`Id_Proveedor` AS `Id_Proveedor`,`Proveedores`.`Proveedor` AS `Proveedor`,`Clientes`.`id_cliente` AS `Id_Cliente`,`Clientes`.`cliente` AS `Cliente` from (`Proveedores` join `Clientes` on((`Proveedores`.`NIF` = `Clientes`.`if`))) */; +/*!50001 VIEW `proveedores_clientes` AS select `Proveedores`.`Id_Proveedor` AS `Id_Proveedor`,`Proveedores`.`Proveedor` AS `Proveedor`,`Clientes`.`id_cliente` AS `Id_Cliente`,`Clientes`.`cliente` AS `Cliente` from (`vn2008`.`Proveedores` join `vn2008`.`Clientes` on((`Proveedores`.`NIF` = `Clientes`.`if`))) */; +/*!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 `province` +-- + +/*!50001 DROP VIEW IF EXISTS `province`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `province` AS select `p`.`id` AS `province_id`,`p`.`name` AS `name`,`p`.`countryFk` AS `Paises_Id`,`p`.`warehouseFk` AS `warehouse_id`,`p`.`zoneFk` AS `zone`,`p`.`geoFk` AS `geoFk`,`p`.`nstGeoFk` AS `nst_geo_id`,`p`.`nstName` AS `nst_name` from `vn`.`province` `p` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `recovery` +-- + +/*!50001 DROP VIEW IF EXISTS `recovery`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `recovery` AS select `r`.`id` AS `recovery_id`,`r`.`clientFk` AS `Id_Cliente`,`r`.`started` AS `dstart`,`r`.`finished` AS `dend`,`r`.`amount` AS `amount`,`r`.`period` AS `period` from `vn`.`recovery` `r` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93280,6 +97384,42 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `sharingcart` +-- + +/*!50001 DROP VIEW IF EXISTS `sharingcart`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sharingcart` AS select `sc`.`id` AS `id`,`sc`.`workerFk` AS `Id_Trabajador`,`sc`.`started` AS `datSTART`,`sc`.`ended` AS `datEND`,`sc`.`workerSubstitute` AS `Id_Suplente`,`sc`.`created` AS `odbc_date` from `vn`.`sharingCart` `sc` */; +/*!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 `sharingclient` +-- + +/*!50001 DROP VIEW IF EXISTS `sharingclient`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sharingclient` AS select `sc`.`id` AS `id`,`sc`.`workerFk` AS `Id_Trabajador`,`sc`.`started` AS `datSTART`,`sc`.`ended` AS `datEND`,`sc`.`clientFk` AS `Id_Cliente` from `vn`.`sharingClient` `sc` */; +/*!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` -- @@ -93298,6 +97438,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `state` +-- + +/*!50001 DROP VIEW IF EXISTS `state`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `state` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`order` AS `order`,`s`.`alertLevel` AS `alert_level`,`s`.`code` AS `code`,`s`.`sectorProdPriority` AS `sectorProdPriority`,`s`.`nextStateFk` AS `nextStateFk`,`s`.`isPreviousPreparable` AS `isPreviousPreparable`,`s`.`isPicked` AS `isPicked` from `vn`.`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 */; + -- -- Final view structure for view `tag` -- @@ -93370,6 +97528,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `ticket_observation` +-- + +/*!50001 DROP VIEW IF EXISTS `ticket_observation`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticket_observation` AS select `to`.`id` AS `ticket_observation_id`,`to`.`ticketFk` AS `Id_Ticket`,`to`.`observationTypeFk` AS `observation_type_id`,`to`.`description` AS `text` from `vn`.`ticketObservation` `to` */; +/*!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 `travel` -- @@ -93401,7 +97577,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_Agenda` AS select 'P' AS `Tipo`,`Proveedores`.`Id_Proveedor` AS `Id`,`Proveedores`.`Proveedor` AS `Nombre`,`Proveedores`.`Telefono` AS `Telephone` from `Proveedores` where (`Proveedores`.`Telefono` is not null) union select 'C' AS `Tipo`,`Clientes`.`id_cliente` AS `Id`,`Clientes`.`cliente` AS `Cliente`,`Clientes`.`telefono` AS `Telefono` from `Clientes` where (`Clientes`.`telefono` is not null) union select 'C' AS `Tipo`,`Clientes`.`id_cliente` AS `Id`,`Clientes`.`cliente` AS `Cliente`,`Clientes`.`movil` AS `Movil` from `Clientes` where (`Clientes`.`movil` is not null) union select if(isnull(`Relaciones`.`Id_Proveedor`),'C','P') AS `Tipo`,if(isnull(`Relaciones`.`Id_Proveedor`),`Relaciones`.`Id_Cliente`,`Relaciones`.`Id_Proveedor`) AS `Id`,`Contactos`.`Nombre` AS `Nombre`,`Contactos`.`Telefono` AS `Telefono` from (`Contactos` join `Relaciones` on((`Contactos`.`Id_Contacto` = `Relaciones`.`Id_Contacto`))) where (`Contactos`.`Telefono` is not null) union select if(isnull(`Relaciones`.`Id_Proveedor`),'C','P') AS `Tipo`,if(isnull(`Relaciones`.`Id_Proveedor`),`Relaciones`.`Id_Cliente`,`Relaciones`.`Id_Proveedor`) AS `Id`,`Contactos`.`Nombre` AS `Nombre`,`Contactos`.`Movil` AS `Movil` from (`Contactos` join `Relaciones` on((`Contactos`.`Id_Contacto` = `Relaciones`.`Id_Contacto`))) where (`Contactos`.`Movil` is not null) union select 'T' AS `Tipo`,`Trabajadores`.`Id_Trabajador` AS `Id_Trabajador`,`Trabajadores`.`CodigoTrabajador` AS `CodigoTrabajador`,`Trabajadores`.`extension` AS `extension` from `Trabajadores` where (`Trabajadores`.`extension` is not null) */; +/*!50001 VIEW `v_Agenda` AS select 'P' AS `Tipo`,`Proveedores`.`Id_Proveedor` AS `Id`,`Proveedores`.`Proveedor` AS `Nombre`,`Proveedores`.`Telefono` AS `Telephone` from `vn2008`.`Proveedores` where (`Proveedores`.`Telefono` is not null) union select 'C' AS `Tipo`,`Clientes`.`id_cliente` AS `Id`,`Clientes`.`cliente` AS `Cliente`,`Clientes`.`telefono` AS `Telefono` from `vn2008`.`Clientes` where (`Clientes`.`telefono` is not null) union select 'C' AS `Tipo`,`Clientes`.`id_cliente` AS `Id`,`Clientes`.`cliente` AS `Cliente`,`Clientes`.`movil` AS `Movil` from `vn2008`.`Clientes` where (`Clientes`.`movil` is not null) union select if(isnull(`vn2008`.`Relaciones`.`Id_Proveedor`),'C','P') AS `Tipo`,if(isnull(`vn2008`.`Relaciones`.`Id_Proveedor`),`vn2008`.`Relaciones`.`Id_Cliente`,`vn2008`.`Relaciones`.`Id_Proveedor`) AS `Id`,`vn2008`.`Contactos`.`Nombre` AS `Nombre`,`vn2008`.`Contactos`.`Telefono` AS `Telefono` from (`vn2008`.`Contactos` join `vn2008`.`Relaciones` on((`vn2008`.`Contactos`.`Id_Contacto` = `vn2008`.`Relaciones`.`Id_Contacto`))) where (`vn2008`.`Contactos`.`Telefono` is not null) union select if(isnull(`vn2008`.`Relaciones`.`Id_Proveedor`),'C','P') AS `Tipo`,if(isnull(`vn2008`.`Relaciones`.`Id_Proveedor`),`vn2008`.`Relaciones`.`Id_Cliente`,`vn2008`.`Relaciones`.`Id_Proveedor`) AS `Id`,`vn2008`.`Contactos`.`Nombre` AS `Nombre`,`vn2008`.`Contactos`.`Movil` AS `Movil` from (`vn2008`.`Contactos` join `vn2008`.`Relaciones` on((`vn2008`.`Contactos`.`Id_Contacto` = `vn2008`.`Relaciones`.`Id_Contacto`))) where (`vn2008`.`Contactos`.`Movil` is not null) union select 'T' AS `Tipo`,`vn2008`.`Trabajadores`.`Id_Trabajador` AS `Id_Trabajador`,`vn2008`.`Trabajadores`.`CodigoTrabajador` AS `CodigoTrabajador`,`vn2008`.`Trabajadores`.`extension` AS `extension` from `vn2008`.`Trabajadores` where (`vn2008`.`Trabajadores`.`extension` is not null) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93419,7 +97595,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_Agenda2` AS select `v_Agenda`.`Tipo` AS `Tipo`,`v_Agenda`.`Id` AS `Id`,`v_Agenda`.`Nombre` AS `Nombre`,replace(`v_Agenda`.`Telephone`,' ','') AS `Telefono` from `v_Agenda` where `v_Agenda`.`Telephone` group by replace(`v_Agenda`.`Telephone`,' ','') */; +/*!50001 VIEW `v_Agenda2` AS select `v_Agenda`.`Tipo` AS `Tipo`,`v_Agenda`.`Id` AS `Id`,`v_Agenda`.`Nombre` AS `Nombre`,replace(`v_Agenda`.`Telephone`,' ','') AS `Telefono` from `vn2008`.`v_Agenda` where `v_Agenda`.`Telephone` group by replace(`v_Agenda`.`Telephone`,' ','') */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93473,7 +97649,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_Ordenes` AS select `Ordenes`.`Id_ORDEN` AS `Id_ORDEN`,`Ordenes`.`ORDEN` AS `ORDEN`,`Ordenes`.`datORDEN` AS `datORDEN`,`Ordenes`.`datTICKET` AS `datTICKET`,`Ordenes`.`CodVENDEDOR` AS `CodVENDEDOR`,`Ordenes`.`CodCOMPRADOR` AS `CodCOMPRADOR`,`Ordenes`.`CANTIDAD` AS `CANTIDAD`,`Ordenes`.`PRECIOMAX` AS `PRECIOMAX`,`Ordenes`.`PREU` AS `PREU`,`Ordenes`.`Id_ARTICLE` AS `Id_ARTICLE`,`Ordenes`.`Id_CLIENTE` AS `Id_CLIENTE`,`Ordenes`.`COMENTARIO` AS `COMENTARIO`,`Ordenes`.`OK` AS `OK`,`Ordenes`.`TOTAL` AS `TOTAL`,`Ordenes`.`datCOMPRA` AS `datCOMPRA`,`Ordenes`.`KO` AS `KO`,`Ordenes`.`Id_Movimiento` AS `Id_Movimiento`,`Ordenes`.`odbc_date` AS `odbc_date` from `Ordenes` */; +/*!50001 VIEW `v_Ordenes` AS select `Ordenes`.`Id_ORDEN` AS `Id_ORDEN`,`Ordenes`.`ORDEN` AS `ORDEN`,`Ordenes`.`datORDEN` AS `datORDEN`,`Ordenes`.`datTICKET` AS `datTICKET`,`Ordenes`.`CodVENDEDOR` AS `CodVENDEDOR`,`Ordenes`.`CodCOMPRADOR` AS `CodCOMPRADOR`,`Ordenes`.`CANTIDAD` AS `CANTIDAD`,`Ordenes`.`PRECIOMAX` AS `PRECIOMAX`,`Ordenes`.`PREU` AS `PREU`,`Ordenes`.`Id_ARTICLE` AS `Id_ARTICLE`,`Ordenes`.`Id_CLIENTE` AS `Id_CLIENTE`,`Ordenes`.`COMENTARIO` AS `COMENTARIO`,`Ordenes`.`OK` AS `OK`,`Ordenes`.`TOTAL` AS `TOTAL`,`Ordenes`.`datCOMPRA` AS `datCOMPRA`,`Ordenes`.`KO` AS `KO`,`Ordenes`.`Id_Movimiento` AS `Id_Movimiento`,`Ordenes`.`odbc_date` AS `odbc_date` from `vn2008`.`Ordenes` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93581,7 +97757,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_barcodes` AS select `vn2008`.`Articles`.`Id_Article` AS `code`,`vn2008`.`Articles`.`Id_Article` AS `Id_Article` from `vn2008`.`Articles` union all select `vn2008`.`barcodes`.`code` AS `code`,`vn2008`.`barcodes`.`Id_Article` AS `Id_Article` from `vn2008`.`barcodes` union all select `c`.`Id_Compra` AS `Id_Compra`,`c`.`Id_Article` AS `Id_Article` from ((`vn2008`.`Compres` `c` join `vn2008`.`Entradas` `e` on((`c`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `tr` on((`tr`.`id` = `e`.`travel_id`))) where (`tr`.`landing` >= (curdate() + interval -(15) day)) */; +/*!50001 VIEW `v_barcodes` AS select `Articles`.`Id_Article` AS `code`,`Articles`.`Id_Article` AS `Id_Article` from `vn2008`.`Articles` union all select `barcodes`.`code` AS `code`,`barcodes`.`Id_Article` AS `Id_Article` from `vn2008`.`barcodes` union all select `c`.`Id_Compra` AS `Id_Compra`,`c`.`Id_Article` AS `Id_Article` from ((`vn2008`.`Compres` `c` join `vn2008`.`Entradas` `e` on((`c`.`Id_Entrada` = `e`.`Id_Entrada`))) join `vn2008`.`travel` `tr` on((`tr`.`id` = `e`.`travel_id`))) where (`tr`.`landing` >= (curdate() + interval -(15) day)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93689,7 +97865,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_empresa` AS select `e`.`logo` AS `logo`,`e`.`id` AS `id`,`e`.`registro` AS `registro`,`e`.`gerente_id` AS `gerente_id`,`e`.`alta` AS `alta`,`t`.`Nombre` AS `Nombre`,`t`.`Apellidos` AS `Apellidos`,`p`.`Proveedor` AS `Proveedor`,`p`.`Domicilio` AS `Domicilio`,`p`.`CP` AS `CP`,`p`.`Localidad` AS `Localidad`,`p`.`NIF` AS `NIF`,`p`.`Telefono` AS `Telefono`,`p`.`Alias` AS `Alias`,`e`.`abbreviation` AS `abbreviation` from ((`empresa` `e` join `Trabajadores` `t` on((`t`.`Id_Trabajador` = `e`.`gerente_id`))) join `Proveedores` `p` on((`p`.`Id_Proveedor` = `e`.`id`))) */; +/*!50001 VIEW `v_empresa` AS select `e`.`logo` AS `logo`,`e`.`id` AS `id`,`e`.`registro` AS `registro`,`e`.`gerente_id` AS `gerente_id`,`e`.`alta` AS `alta`,`t`.`Nombre` AS `Nombre`,`t`.`Apellidos` AS `Apellidos`,`p`.`Proveedor` AS `Proveedor`,`p`.`Domicilio` AS `Domicilio`,`p`.`CP` AS `CP`,`p`.`Localidad` AS `Localidad`,`p`.`NIF` AS `NIF`,`p`.`Telefono` AS `Telefono`,`p`.`Alias` AS `Alias`,`e`.`abbreviation` AS `abbreviation` from ((`vn2008`.`empresa` `e` join `vn2008`.`Trabajadores` `t` on((`t`.`Id_Trabajador` = `e`.`gerente_id`))) join `vn2008`.`Proveedores` `p` on((`p`.`Id_Proveedor` = `e`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93707,7 +97883,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_encajado` AS select hour(`e`.`odbc_date`) AS `hora`,minute(`e`.`odbc_date`) AS `minuto`,ifnull(`c`.`Volumen`,94500) AS `cm3`,`t`.`warehouse_id` AS `warehouse_id` from ((`expeditions` `e` left join `Cubos` `c` on((`c`.`item_id` = `e`.`EsBulto`))) join `Tickets` `t` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) where (`e`.`odbc_date` between curdate() and `DAYEND`(curdate())) */; +/*!50001 VIEW `v_encajado` AS select hour(`e`.`odbc_date`) AS `hora`,minute(`e`.`odbc_date`) AS `minuto`,ifnull(`c`.`Volumen`,94500) AS `cm3`,`t`.`warehouse_id` AS `warehouse_id` from ((`vn2008`.`expeditions` `e` left join `vn2008`.`Cubos` `c` on((`c`.`item_id` = `e`.`EsBulto`))) join `vn2008`.`Tickets` `t` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) where (`e`.`odbc_date` between curdate() and `DAYEND`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93725,7 +97901,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_encajado_ultima_hora` AS select sum((ifnull(`c`.`Volumen`,94500) / 1000000)) AS `m3`,`t`.`warehouse_id` AS `warehouse_id` from ((`expeditions` `e` left join `Cubos` `c` on((`c`.`item_id` = `e`.`EsBulto`))) join `Tickets` `t` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) where ((`e`.`odbc_date` > (now() + interval -(1) hour)) and (`t`.`warehouse_id` in (1,44))) group by `t`.`warehouse_id` */; +/*!50001 VIEW `v_encajado_ultima_hora` AS select sum((ifnull(`c`.`Volumen`,94500) / 1000000)) AS `m3`,`t`.`warehouse_id` AS `warehouse_id` from ((`vn2008`.`expeditions` `e` left join `vn2008`.`Cubos` `c` on((`c`.`item_id` = `e`.`EsBulto`))) join `vn2008`.`Tickets` `t` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) where ((`e`.`odbc_date` > (now() + interval -(1) hour)) and (`t`.`warehouse_id` in (1,44))) group by `t`.`warehouse_id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93743,7 +97919,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_expeditions_shipping_charge2` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`az`.`price` AS `shipping_charge`,`t`.`Fecha` AS `Fecha`,`t`.`warehouse_id` AS `warehouse_id` from ((((((`Tickets` `t` left join `Clientes` `cli` on((`cli`.`id_cliente` = `t`.`Id_Cliente`))) left join `expeditions` `e` on((`e`.`ticket_id` = `t`.`Id_Ticket`))) join `Consignatarios` `c` on((`c`.`id_consigna` = `t`.`Id_Consigna`))) join `Agencias` `a` on((`a`.`Id_Agencia` = `t`.`Id_Agencia`))) join `Agencias_province` `ap` on(((`t`.`warehouse_id` = `ap`.`warehouse_id`) and (`ap`.`province_id` = `c`.`province_id`) and (`ap`.`agency_id` = `a`.`agency_id`)))) join `Agencias_zonas` `az` on(((`az`.`Id_Agencia` = `t`.`Id_Agencia`) and (`az`.`zona` = `ap`.`zona`) and (`t`.`warehouse_id` = `az`.`warehouse_id`) and (`az`.`Id_Article` = `e`.`EsBulto`)))) where ((`t`.`Fecha` >= '2015-01-01') and (`cli`.`real` <> 0) and (`t`.`empresa_id` in (442,567))) */; +/*!50001 VIEW `v_expeditions_shipping_charge2` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`az`.`price` AS `shipping_charge`,`t`.`Fecha` AS `Fecha`,`t`.`warehouse_id` AS `warehouse_id` from ((((((`vn2008`.`Tickets` `t` left join `vn2008`.`Clientes` `cli` on((`cli`.`id_cliente` = `t`.`Id_Cliente`))) left join `vn2008`.`expeditions` `e` on((`e`.`ticket_id` = `t`.`Id_Ticket`))) join `vn2008`.`Consignatarios` `c` on((`c`.`id_consigna` = `t`.`Id_Consigna`))) join `vn2008`.`Agencias` `a` on((`a`.`Id_Agencia` = `t`.`Id_Agencia`))) join `vn2008`.`Agencias_province` `ap` on(((`t`.`warehouse_id` = `ap`.`warehouse_id`) and (`ap`.`province_id` = `c`.`province_id`) and (`ap`.`agency_id` = `a`.`agency_id`)))) join `vn2008`.`Agencias_zonas` `az` on(((`az`.`Id_Agencia` = `t`.`Id_Agencia`) and (`az`.`zona` = `ap`.`zona`) and (`t`.`warehouse_id` = `az`.`warehouse_id`) and (`az`.`Id_Article` = `e`.`EsBulto`)))) where ((`t`.`Fecha` >= '2015-01-01') and (`cli`.`real` <> 0) and (`t`.`empresa_id` in (442,567))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93761,7 +97937,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_expeditions_shipping_charge_by_container` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Fecha` AS `Fecha`,`az`.`Id_Article` AS `Id_Article`,`az`.`price` AS `price`,`t`.`Id_Ruta` AS `Id_Ruta` from ((((((`Tickets` `t` join `Clientes` `cli` on((`cli`.`id_cliente` = `t`.`Id_Cliente`))) left join `expeditions` `e` on((`e`.`ticket_id` = `t`.`Id_Ticket`))) join `Consignatarios` `c` on((`c`.`id_consigna` = `t`.`Id_Consigna`))) join `Agencias` `a` on((`a`.`Id_Agencia` = `t`.`Id_Agencia`))) join `Agencias_province` `ap` on(((`t`.`warehouse_id` = `ap`.`warehouse_id`) and (`ap`.`province_id` = `c`.`province_id`) and (`ap`.`agency_id` = `a`.`agency_id`)))) join `Agencias_zonas` `az` on(((`az`.`Id_Agencia` = `t`.`Id_Agencia`) and (`az`.`zona` = `ap`.`zona`) and (`t`.`warehouse_id` = `az`.`warehouse_id`) and (`az`.`Id_Article` = `e`.`EsBulto`)))) where ((`t`.`Fecha` >= '2016-10-01') and (`cli`.`real` <> 0) and (`t`.`empresa_id` in (442,791,567))) */; +/*!50001 VIEW `v_expeditions_shipping_charge_by_container` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Fecha` AS `Fecha`,`az`.`Id_Article` AS `Id_Article`,`az`.`price` AS `price`,`t`.`Id_Ruta` AS `Id_Ruta` from ((((((`vn2008`.`Tickets` `t` join `vn2008`.`Clientes` `cli` on((`cli`.`id_cliente` = `t`.`Id_Cliente`))) left join `vn2008`.`expeditions` `e` on((`e`.`ticket_id` = `t`.`Id_Ticket`))) join `vn2008`.`Consignatarios` `c` on((`c`.`id_consigna` = `t`.`Id_Consigna`))) join `vn2008`.`Agencias` `a` on((`a`.`Id_Agencia` = `t`.`Id_Agencia`))) join `vn2008`.`Agencias_province` `ap` on(((`t`.`warehouse_id` = `ap`.`warehouse_id`) and (`ap`.`province_id` = `c`.`province_id`) and (`ap`.`agency_id` = `a`.`agency_id`)))) join `vn2008`.`Agencias_zonas` `az` on(((`az`.`Id_Agencia` = `t`.`Id_Agencia`) and (`az`.`zona` = `ap`.`zona`) and (`t`.`warehouse_id` = `az`.`warehouse_id`) and (`az`.`Id_Article` = `e`.`EsBulto`)))) where ((`t`.`Fecha` >= '2016-10-01') and (`cli`.`real` <> 0) and (`t`.`empresa_id` in (442,791,567))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93833,7 +98009,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_location` AS select `tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude`,`t`.`Id_Consigna` AS `Id_Consigna` from (`ticket_location` `tl` join `Tickets` `t` on((`t`.`Id_Ticket` = `tl`.`Id_Ticket`))) where (`t`.`Fecha` >= (curdate() + interval -(3) month)) group by `t`.`Id_Consigna` order by `t`.`Id_Ticket` desc */; +/*!50001 VIEW `v_location` AS select `tl`.`longitude` AS `longitude`,`tl`.`latitude` AS `latitude`,`t`.`Id_Consigna` AS `Id_Consigna` from (`vn2008`.`ticket_location` `tl` join `vn2008`.`Tickets` `t` on((`t`.`Id_Ticket` = `tl`.`Id_Ticket`))) where (`t`.`Fecha` >= (curdate() + interval -(3) month)) group by `t`.`Id_Consigna` order by `t`.`Id_Ticket` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93887,7 +98063,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_movimientos_mark` AS select `Movimientos_mark`.`Id_Movimiento` AS `Id_Movimiento`,max(`Movimientos_mark`.`Id_Accion`) AS `Accion` from `Movimientos_mark` group by `Movimientos_mark`.`Id_Movimiento` having ((max(`Movimientos_mark`.`Id_Accion`) = '6') or (max(`Movimientos_mark`.`Id_Accion`) = '7')) */; +/*!50001 VIEW `v_movimientos_mark` AS select `Movimientos_mark`.`Id_Movimiento` AS `Id_Movimiento`,max(`Movimientos_mark`.`Id_Accion`) AS `Accion` from `vn2008`.`Movimientos_mark` group by `Movimientos_mark`.`Id_Movimiento` having ((max(`Movimientos_mark`.`Id_Accion`) = '6') or (max(`Movimientos_mark`.`Id_Accion`) = '7')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93905,7 +98081,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_phonebook` AS select `Clientes`.`id_cliente` AS `Id_Cliente`,replace(`Clientes`.`telefono`,' ','') AS `Telefono` from `Clientes` where (`Clientes`.`telefono` and `Clientes`.`activo`) union select `Clientes`.`id_cliente` AS `Id_Cliente`,replace(`Clientes`.`movil`,' ','') AS `Movil` from `Clientes` where (`Clientes`.`movil` and `Clientes`.`activo`) union select `Consignatarios`.`Id_cliente` AS `Id_Cliente`,replace(`Consignatarios`.`telefono`,' ','') AS `TRIM(telefono)` from (`Consignatarios` join `Clientes` `c` on((`Consignatarios`.`Id_cliente` = `c`.`id_cliente`))) where (`Consignatarios`.`telefono` and `c`.`activo`) union select `Consignatarios`.`Id_cliente` AS `Id_Cliente`,replace(`Consignatarios`.`movil`,' ','') AS `TRIM(movil)` from (`Consignatarios` join `Clientes` `c` on((`Consignatarios`.`Id_cliente` = `c`.`id_cliente`))) where (`Consignatarios`.`movil` and `c`.`activo`) union select `r`.`Id_Cliente` AS `Id_Cliente`,replace(`c`.`Telefono`,' ','') AS `REPLACE(c.telefono,' ','')` from ((`Clientes` `cl` join `Relaciones` `r` on((`cl`.`id_cliente` = `r`.`Id_Cliente`))) join `Contactos` `c` on((`r`.`Id_Contacto` = `c`.`Id_Contacto`))) where (`cl`.`telefono` and `cl`.`activo`) union select `r`.`Id_Cliente` AS `Id_Cliente`,replace(`c`.`Movil`,' ','') AS `REPLACE(c.Movil,' ','')` from ((`Clientes` `cl` join `Relaciones` `r` on((`cl`.`id_cliente` = `r`.`Id_Cliente`))) join `Contactos` `c` on((`r`.`Id_Contacto` = `c`.`Id_Contacto`))) where (`cl`.`movil` and `cl`.`activo`) */; +/*!50001 VIEW `v_phonebook` AS select `Clientes`.`id_cliente` AS `Id_Cliente`,replace(`Clientes`.`telefono`,' ','') AS `Telefono` from `vn2008`.`Clientes` where (`Clientes`.`telefono` and `Clientes`.`activo`) union select `Clientes`.`id_cliente` AS `Id_Cliente`,replace(`Clientes`.`movil`,' ','') AS `Movil` from `vn2008`.`Clientes` where (`Clientes`.`movil` and `Clientes`.`activo`) union select `vn2008`.`Consignatarios`.`Id_cliente` AS `Id_Cliente`,replace(`vn2008`.`Consignatarios`.`telefono`,' ','') AS `TRIM(telefono)` from (`vn2008`.`Consignatarios` join `vn2008`.`Clientes` `c` on((`vn2008`.`Consignatarios`.`Id_cliente` = `c`.`id_cliente`))) where (`vn2008`.`Consignatarios`.`telefono` and `c`.`activo`) union select `vn2008`.`Consignatarios`.`Id_cliente` AS `Id_Cliente`,replace(`vn2008`.`Consignatarios`.`movil`,' ','') AS `TRIM(movil)` from (`vn2008`.`Consignatarios` join `vn2008`.`Clientes` `c` on((`vn2008`.`Consignatarios`.`Id_cliente` = `c`.`id_cliente`))) where (`vn2008`.`Consignatarios`.`movil` and `c`.`activo`) union select `r`.`Id_Cliente` AS `Id_Cliente`,replace(`c`.`Telefono`,' ','') AS `REPLACE(c.telefono,' ','')` from ((`vn2008`.`Clientes` `cl` join `vn2008`.`Relaciones` `r` on((`cl`.`id_cliente` = `r`.`Id_Cliente`))) join `vn2008`.`Contactos` `c` on((`r`.`Id_Contacto` = `c`.`Id_Contacto`))) where (`cl`.`telefono` and `cl`.`activo`) union select `r`.`Id_Cliente` AS `Id_Cliente`,replace(`c`.`Movil`,' ','') AS `REPLACE(c.Movil,' ','')` from ((`vn2008`.`Clientes` `cl` join `vn2008`.`Relaciones` `r` on((`cl`.`id_cliente` = `r`.`Id_Cliente`))) join `vn2008`.`Contactos` `c` on((`r`.`Id_Contacto` = `c`.`Id_Contacto`))) where (`cl`.`movil` and `cl`.`activo`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -93977,7 +98153,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_ticket_amount` AS select `Movimientos`.`Id_Ticket` AS `Id_Ticket`,sum((((`Movimientos`.`Cantidad` * `Movimientos`.`Preu`) * (100 - `Movimientos`.`Descuento`)) / 100)) AS `amount` from (`Movimientos` join `Tickets` on((`Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`))) where (`Tickets`.`Fecha` >= (curdate() + interval -(6) month)) group by `Movimientos`.`Id_Ticket` */; +/*!50001 VIEW `v_ticket_amount` AS select `Movimientos`.`Id_Ticket` AS `Id_Ticket`,sum((((`Movimientos`.`Cantidad` * `Movimientos`.`Preu`) * (100 - `Movimientos`.`Descuento`)) / 100)) AS `amount` from (`vn2008`.`Movimientos` join `vn2008`.`Tickets` on((`Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket`))) where (`Tickets`.`Fecha` >= (curdate() + interval -(6) month)) group by `Movimientos`.`Id_Ticket` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94031,7 +98207,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 `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 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 ((((((((`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((`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 */; @@ -94067,7 +98243,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_xsubclien` AS select distinct `Facturas`.`Id_Cliente` AS `Id_Cliente`,`Facturas`.`empresa_id` AS `empresa_id` from `Facturas` where (`Facturas`.`Fecha` > (curdate() + interval -(2) month)) union select `Recibos`.`Id_Cliente` AS `Id_Cliente`,`Recibos`.`empresa_id` AS `empresa_id` from `Recibos` where (`Recibos`.`Fechacobro` > (curdate() + interval -(2) month)) */; +/*!50001 VIEW `v_xsubclien` AS select distinct `Facturas`.`Id_Cliente` AS `Id_Cliente`,`Facturas`.`empresa_id` AS `empresa_id` from `vn2008`.`Facturas` where (`Facturas`.`Fecha` > (curdate() + interval -(2) month)) union select `vn2008`.`Recibos`.`Id_Cliente` AS `Id_Cliente`,`vn2008`.`Recibos`.`empresa_id` AS `empresa_id` from `vn2008`.`Recibos` where (`vn2008`.`Recibos`.`Fechacobro` > (curdate() + interval -(2) month)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94085,7 +98261,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_xsubcuentas` AS select `Clientes`.`Cuenta` AS `COD`,`Clientes`.`razonSocial` AS `TITULO`,concat(if(((`p`.`CEE` = 1) and (ascii(left(`Clientes`.`if`,1)) < 58)),`p`.`Codigo`,''),`Clientes`.`if`) AS `NIF`,`Clientes`.`domicilio` AS `DOMICILIO`,`Clientes`.`poblacion` AS `POBLACION`,`province`.`name` AS `PROVINCIA`,`Clientes`.`codPostal` AS `CODPOSTAL`,`p`.`Codigo` AS `country_code`,`v_xsubclien`.`empresa_id` AS `empresa_id`,substr(`Clientes`.`e-mail`,1,(coalesce(nullif(locate(',',`Clientes`.`e-mail`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((`Clientes` join `v_xsubclien` on((`Clientes`.`id_cliente` = `v_xsubclien`.`Id_Cliente`))) left join `Paises` `p` on((`p`.`Id` = `Clientes`.`Id_Pais`))) join `province` on((`Clientes`.`province_id` = `province`.`province_id`))) where (`Clientes`.`oficial` <> 0) group by `Clientes`.`id_cliente`,`v_xsubclien`.`empresa_id` union all select `Proveedores`.`cuenta` AS `Cuenta`,`Proveedores`.`Proveedor` AS `Proveedor`,concat(if(((`p`.`CEE` = 1) and (ascii(left(`Proveedores`.`NIF`,1)) < 58)),`p`.`Codigo`,''),`Proveedores`.`NIF`) AS `NIF`,`Proveedores`.`Domicilio` AS `Domicilio`,`Proveedores`.`Localidad` AS `Localidad`,`prov`.`name` AS `Provincia`,`Proveedores`.`CP` AS `CP`,`p`.`Codigo` AS `country_code`,`v_xsubprov`.`empresa_id` AS `empresa_id`,substr(`c`.`email`,1,(coalesce(nullif(locate(',',`c`.`email`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((((`Proveedores` join `v_xsubprov` on((`Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id`))) left join `Paises` `p` on((`p`.`Id` = `Proveedores`.`pais_id`))) left join `province` `prov` on((`prov`.`province_id` = `Proveedores`.`province_id`))) left join `Relaciones` `r` on((`r`.`Id_Proveedor` = `Proveedores`.`Id_Proveedor`))) left join `Contactos` `c` on((`c`.`Id_Contacto` = `r`.`Id_Contacto`))) where (`Proveedores`.`oficial` <> 0) group by `v_xsubprov`.`proveedor_id`,`v_xsubprov`.`empresa_id` union all select `Gastos`.`Id_Gasto` AS `Id_Gasto`,`Gastos`.`Gasto` AS `Gasto`,NULL AS `NULL`,NULL AS `My_exp_NULL`,NULL AS `My_exp_1_NULL`,NULL AS `My_exp_2_NULL`,NULL AS `My_exp_3_NULL`,NULL AS `country_code`,`e`.`id` AS `id`,NULL AS `EMAIL`,1 AS `IDNIF` from (`Gastos` join `empresa` `e` on((`e`.`id` = 442))) union all select `Bancos`.`Cuenta` AS `Cuenta`,`Bancos`.`Banco` AS `Banco`,NULL AS `NULL`,NULL AS `My_exp_NULL`,NULL AS `My_exp_1_NULL`,NULL AS `My_exp_2_NULL`,NULL AS `My_exp_3_NULL`,NULL AS `country_code`,`e`.`id` AS `id`,NULL AS `EMAIL`,1 AS `IDNIF` from (`Bancos` join `empresa` `e` on((`e`.`id` = 442))) union all select lpad(right(`Proveedores`.`cuenta`,5),10,'47510000') AS `Cuenta`,`Proveedores`.`Proveedor` AS `Proveedor`,`Proveedores`.`NIF` AS `NIF`,`Proveedores`.`Domicilio` AS `Domicilio`,`Proveedores`.`Localidad` AS `Localidad`,`prov`.`name` AS `Provincia`,`Proveedores`.`CP` AS `CP`,`p`.`Codigo` AS `country_code`,`v_xsubprov`.`empresa_id` AS `empresa_id`,substr(`c`.`email`,1,(coalesce(nullif(locate(',',`c`.`email`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((((`Proveedores` join `v_xsubprov` on((`Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id`))) left join `Paises` `p` on((`p`.`Id` = `Proveedores`.`pais_id`))) left join `province` `prov` on((`prov`.`province_id` = `Proveedores`.`province_id`))) left join `Relaciones` `r` on((`r`.`Id_Proveedor` = `Proveedores`.`Id_Proveedor`))) left join `Contactos` `c` on((`c`.`Id_Contacto` = `r`.`Id_Contacto`))) where (((`Proveedores`.`cuenta` like '_____3____') or (`Proveedores`.`cuenta` like '_____2____')) and (`Proveedores`.`oficial` = 1)) group by `v_xsubprov`.`proveedor_id`,`v_xsubprov`.`empresa_id` */; +/*!50001 VIEW `v_xsubcuentas` AS select `Clientes`.`Cuenta` AS `COD`,`Clientes`.`razonSocial` AS `TITULO`,concat(if(((`p`.`CEE` = 1) and (ascii(left(`Clientes`.`if`,1)) < 58)),`p`.`Codigo`,''),`Clientes`.`if`) AS `NIF`,`Clientes`.`domicilio` AS `DOMICILIO`,`Clientes`.`poblacion` AS `POBLACION`,`province`.`name` AS `PROVINCIA`,`Clientes`.`codPostal` AS `CODPOSTAL`,`p`.`Codigo` AS `country_code`,`v_xsubclien`.`empresa_id` AS `empresa_id`,substr(`Clientes`.`e-mail`,1,(coalesce(nullif(locate(',',`Clientes`.`e-mail`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((`vn2008`.`Clientes` join `vn2008`.`v_xsubclien` on((`Clientes`.`id_cliente` = `v_xsubclien`.`Id_Cliente`))) left join `vn2008`.`Paises` `p` on((`p`.`Id` = `Clientes`.`Id_Pais`))) join `vn2008`.`province` on((`Clientes`.`province_id` = `province`.`province_id`))) where (`Clientes`.`oficial` <> 0) group by `Clientes`.`id_cliente`,`v_xsubclien`.`empresa_id` union all select `Proveedores`.`cuenta` AS `Cuenta`,`Proveedores`.`Proveedor` AS `Proveedor`,concat(if(((`p`.`CEE` = 1) and (ascii(left(`Proveedores`.`NIF`,1)) < 58)),`p`.`Codigo`,''),`Proveedores`.`NIF`) AS `NIF`,`Proveedores`.`Domicilio` AS `Domicilio`,`Proveedores`.`Localidad` AS `Localidad`,`prov`.`name` AS `Provincia`,`Proveedores`.`CP` AS `CP`,`p`.`Codigo` AS `country_code`,`v_xsubprov`.`empresa_id` AS `empresa_id`,substr(`c`.`email`,1,(coalesce(nullif(locate(',',`c`.`email`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((((`vn2008`.`Proveedores` join `vn2008`.`v_xsubprov` on((`Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id`))) left join `vn2008`.`Paises` `p` on((`p`.`Id` = `Proveedores`.`pais_id`))) left join `vn2008`.`province` `prov` on((`prov`.`province_id` = `Proveedores`.`province_id`))) left join `vn2008`.`Relaciones` `r` on((`r`.`Id_Proveedor` = `Proveedores`.`Id_Proveedor`))) left join `vn2008`.`Contactos` `c` on((`c`.`Id_Contacto` = `r`.`Id_Contacto`))) where (`Proveedores`.`oficial` <> 0) group by `v_xsubprov`.`proveedor_id`,`v_xsubprov`.`empresa_id` union all select `Gastos`.`Id_Gasto` AS `Id_Gasto`,`Gastos`.`Gasto` AS `Gasto`,NULL AS `NULL`,NULL AS `My_exp_NULL`,NULL AS `My_exp_1_NULL`,NULL AS `My_exp_2_NULL`,NULL AS `My_exp_3_NULL`,NULL AS `country_code`,`e`.`id` AS `id`,NULL AS `EMAIL`,1 AS `IDNIF` from (`vn2008`.`Gastos` join `vn2008`.`empresa` `e` on((`e`.`id` = 442))) union all select `Bancos`.`Cuenta` AS `Cuenta`,`Bancos`.`Banco` AS `Banco`,NULL AS `NULL`,NULL AS `My_exp_NULL`,NULL AS `My_exp_1_NULL`,NULL AS `My_exp_2_NULL`,NULL AS `My_exp_3_NULL`,NULL AS `country_code`,`e`.`id` AS `id`,NULL AS `EMAIL`,1 AS `IDNIF` from (`vn2008`.`Bancos` join `vn2008`.`empresa` `e` on((`e`.`id` = 442))) union all select lpad(right(`Proveedores`.`cuenta`,5),10,'47510000') AS `Cuenta`,`Proveedores`.`Proveedor` AS `Proveedor`,`Proveedores`.`NIF` AS `NIF`,`Proveedores`.`Domicilio` AS `Domicilio`,`Proveedores`.`Localidad` AS `Localidad`,`prov`.`name` AS `Provincia`,`Proveedores`.`CP` AS `CP`,`p`.`Codigo` AS `country_code`,`v_xsubprov`.`empresa_id` AS `empresa_id`,substr(`c`.`email`,1,(coalesce(nullif(locate(',',`c`.`email`),0),99) - 1)) AS `EMAIL`,if((`p`.`CEE` = 0),1,if((`p`.`CEE` = 1),2,4)) AS `IDNIF` from (((((`vn2008`.`Proveedores` join `vn2008`.`v_xsubprov` on((`Proveedores`.`Id_Proveedor` = `v_xsubprov`.`proveedor_id`))) left join `vn2008`.`Paises` `p` on((`p`.`Id` = `Proveedores`.`pais_id`))) left join `vn2008`.`province` `prov` on((`prov`.`province_id` = `Proveedores`.`province_id`))) left join `vn2008`.`Relaciones` `r` on((`r`.`Id_Proveedor` = `Proveedores`.`Id_Proveedor`))) left join `vn2008`.`Contactos` `c` on((`c`.`Id_Contacto` = `r`.`Id_Contacto`))) where (((`Proveedores`.`cuenta` like '_____3____') or (`Proveedores`.`cuenta` like '_____2____')) and (`Proveedores`.`oficial` = 1)) group by `v_xsubprov`.`proveedor_id`,`v_xsubprov`.`empresa_id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94206,30 +98382,12 @@ USE `vn2008`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `zoneNickname` 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 */; - --- --- 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 VIEW `zoneNickname` 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 (`vn2008`.`Agencias_province` `ap` join `vn2008`.`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 */; @@ -94249,4 +98407,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-16 13:00:36 +-- Dump completed on 2019-10-14 10:37:03 diff --git a/db/export-data.sh b/db/export-data.sh index 1f5e4fe04..7b694ccde 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -45,20 +45,20 @@ TABLES=( claimReason claimRedelivery claimResult + ticketUpdateAction + state ) dump_tables ${TABLES[@]} TABLES=( vn2008 accion_dits - bionic_updating_options businessReasonEnd container department escritos Grupos iva_group_codigo - state tarifa_componentes tarifa_componentes_series ) diff --git a/e2e/helpers/components_selectors.js b/e2e/helpers/components_selectors.js index 4cd8241ab..3e2715ba2 100644 --- a/e2e/helpers/components_selectors.js +++ b/e2e/helpers/components_selectors.js @@ -1,6 +1,6 @@ export default { - vnTextfield: 'vn-textfield > div > div > div > input', - vnInputNumber: 'vn-input-number > div > div > div > input', + vnTextfield: 'vn-textfield input', + vnInputNumber: 'vn-input-number input', vnSubmit: 'vn-submit > input', vnFloatButton: 'vn-float-button > button' }; diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 081332337..fb36e3279 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -18,8 +18,11 @@ let actions = { clearInput: function(selector, done) { this.wait(selector) - .evaluate(inputSelector => { - return document.querySelector(inputSelector).closest('*[model], *[field], *[value]').$ctrl.value = ''; + .evaluate(selector => { + let $ctrl = document.querySelector(selector).closest('.vn-field').$ctrl; + $ctrl.field = null; + $ctrl.$.$apply(); + $ctrl.input.dispatchEvent(new Event('change')); }, selector) .then(done) .catch(done); @@ -31,6 +34,7 @@ let actions = { let doLogin = () => { this.wait(`vn-login input[name=user]`) + .clearInput(`vn-login input[name=user]`) .write(`vn-login input[name=user]`, userName) .write(`vn-login input[name=password]`, 'nightmare') .click(`vn-login input[type=submit]`) @@ -75,7 +79,7 @@ let actions = { }, changeLanguageToEnglish: function(done) { - let langSelector = '.user-configuration vn-autocomplete[field="$ctrl.lang"]'; + let langSelector = '.user-popover vn-autocomplete[ng-model="$ctrl.lang"]'; this.waitToClick('#user') .wait(langSelector) @@ -167,8 +171,8 @@ let actions = { focusElement: function(selector, done) { this.wait(selector) - .evaluate_now(elemenetSelector => { - let element = document.querySelector(elemenetSelector); + .evaluate_now(selector => { + let element = document.querySelector(selector); element.focus(); }, done, selector) .then(done) @@ -401,8 +405,7 @@ let actions = { }, autocompleteSearch: function(autocompleteSelector, searchValue, done) { - this.wait(`${autocompleteSelector} input`) - .waitToClick(`${autocompleteSelector} input`) + this.waitToClick(`${autocompleteSelector} input`) .write(`.vn-popover.shown .vn-drop-down input`, searchValue) .waitToClick(`.vn-popover.shown .vn-drop-down li.active`) .wait((autocompleteSelector, searchValue) => { @@ -412,7 +415,7 @@ let actions = { }, autocompleteSelector, searchValue) .then(done) .catch(() => { - done(new Error(`.autocompleteSearch() for ${autocompleteSelector}, timed out`)); + done(new Error(`.autocompleteSearch() for value ${searchValue} in ${autocompleteSelector} timed out`)); }); }, @@ -427,25 +430,22 @@ let actions = { .catch(done); }, - datePicker: function(datePickerSelector, changeMonth, day, done) { - this.wait(datePickerSelector) - .mousedown(datePickerSelector) - .wait('div.flatpickr-calendar.open'); + datePicker: function(selector, changeMonth, day, done) { + this.wait(selector) + .mousedown(`${selector} input`) + .wait('.flatpickr-calendar.open'); + if (changeMonth > 0) - this.mousedown('body > div.flatpickr-calendar.open > div.flatpickr-months > span.flatpickr-next-month > svg'); - - + this.mousedown(`.flatpickr-calendar.open .flatpickr-next-month`); if (changeMonth < 0) - this.mousedown('body > div.flatpickr-calendar.open > div.flatpickr-months > span.flatpickr-prev-month > svg'); + this.mousedown(`.flatpickr-calendar.open .flatpickr-prev-month`); let daySelector; if (!day) - daySelector = 'div.flatpickr-calendar.open span.flatpickr-day:nth-child(16)'; - + daySelector = `.flatpickr-calendar.open .flatpickr-day:nth-child(16)`; if (day) - daySelector = `span.flatpickr-day[aria-label~="${day},"]:not(.prevMonthDay):not(.nextMonthDay)`; - + daySelector = `.flatpickr-calendar.open .flatpickr-day[aria-label~="${day},"]:not(.prevMonthDay):not(.nextMonthDay)`; this.wait(selector => { return document.querySelector(selector); diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index a76b50093..75794c28d 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -10,7 +10,10 @@ module.exports = function createNightmare(width = 1280, height = 720) { typeInterval: 10, x: 0, y: 0, - waitTimeout: 2000 + waitTimeout: 2000, + // openDevTools: { + // mode: 'detach' + // } }).viewport(width, height); nightmare.on('console', (type, message, ...args) => { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 351053a02..5d8fd487c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -11,14 +11,14 @@ export default { claimsButton: '.modules-menu > li[ui-sref="claim.index"]', returnToModuleIndexButton: 'a[ui-sref="order.index"]', userMenuButton: 'vn-topbar #user', - userLocalWarehouse: '.user-configuration vn-autocomplete[field="$ctrl.localWarehouseFk"]', - userLocalBank: '.user-configuration vn-autocomplete[field="$ctrl.localBankFk"]', - userLocalCompany: '.user-configuration vn-autocomplete[field="$ctrl.localCompanyFk"]', - userWarehouse: '.user-configuration vn-autocomplete[field="$ctrl.warehouseFk"]', - userCompany: '.user-configuration vn-autocomplete[field="$ctrl.companyFk"]', - userConfigFirstAutocompleteClear: '#localWarehouse > div > div > div > vn-icon.clear', - userConfigSecondAutocompleteClear: '#localBank > div > div > div > vn-icon.clear', - userConfigThirdAutocompleteClear: '#localCompany > div > div > div > vn-icon.clear', + userLocalWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.localWarehouseFk"]', + userLocalBank: '.user-popover vn-autocomplete[ng-model="$ctrl.localBankFk"]', + userLocalCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.localCompanyFk"]', + userWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.warehouseFk"]', + userCompany: '.user-popover vn-autocomplete[ng-model="$ctrl.companyFk"]', + userConfigFirstAutocompleteClear: '#localWarehouse .icons > vn-icon[icon=clear]', + userConfigSecondAutocompleteClear: '#localBank .icons > vn-icon[icon=clear]', + userConfigThirdAutocompleteClear: '#localCompany .icons > vn-icon[icon=clear]', acceptButton: 'vn-confirm button[response=ACCEPT]' }, clientsIndex: { @@ -35,11 +35,11 @@ export default { street: `${components.vnTextfield}[name="street"]`, postcode: `${components.vnTextfield}[name="postcode"]`, city: `${components.vnTextfield}[name="city"]`, - province: `vn-autocomplete[field="$ctrl.client.provinceFk"]`, - country: `vn-autocomplete[field="$ctrl.client.countryFk"]`, + province: `vn-autocomplete[ng-model="$ctrl.client.provinceFk"]`, + country: `vn-autocomplete[ng-model="$ctrl.client.countryFk"]`, userName: `${components.vnTextfield}[name="userName"]`, email: `${components.vnTextfield}[name="email"]`, - salesPersonAutocomplete: `vn-autocomplete[field="$ctrl.client.salesPersonFk"]`, + salesPersonAutocomplete: `vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]`, createButton: `${components.vnSubmit}`, cancelButton: 'vn-button[href="#!/client/index"]' }, @@ -49,13 +49,13 @@ export default { }, clientBasicData: { basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]', - nameInput: 'vn-textfield[field="$ctrl.client.name"] input', - contactInput: 'vn-textfield[field="$ctrl.client.contact"] input', - phoneInput: 'vn-textfield[field="$ctrl.client.phone"] input', - mobileInput: 'vn-textfield[field="$ctrl.client.mobile"] input', - emailInput: 'vn-textfield[field="$ctrl.client.email"] input', - salesPersonAutocomplete: 'vn-autocomplete[field="$ctrl.client.salesPersonFk"]', - channelAutocomplete: 'vn-autocomplete[field="$ctrl.client.contactChannelFk"]', + nameInput: 'vn-textfield[ng-model="$ctrl.client.name"] input', + contactInput: 'vn-textfield[ng-model="$ctrl.client.contact"] input', + phoneInput: 'vn-textfield[ng-model="$ctrl.client.phone"] input', + mobileInput: 'vn-textfield[ng-model="$ctrl.client.mobile"] input', + emailInput: 'vn-textfield[ng-model="$ctrl.client.email"] input', + salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', + channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]', saveButton: `${components.vnSubmit}` }, clientFiscalData: { @@ -67,8 +67,8 @@ export default { addressInput: `${components.vnTextfield}[name="street"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`, cityInput: `${components.vnTextfield}[name="city"]`, - provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]', - countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]', + provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', + countryAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.countryFk"]', activeCheckbox: 'vn-check[label="Active"]', frozenCheckbox: 'vn-check[label="Frozen"]', invoiceByAddressCheckbox: 'vn-check[label="Invoice by address"]', @@ -79,14 +79,14 @@ export default { saveButton: `${components.vnSubmit}` }, clientBillingData: { - payMethodAutocomplete: 'vn-autocomplete[field="$ctrl.client.payMethodFk"]', - IBANInput: `${components.vnTextfield}[name="iban"]`, - dueDayInput: `${components.vnInputNumber}[name="dueDay"]`, - receivedCoreLCRCheckbox: 'vn-check[label="Received LCR"]', - receivedCoreVNLCheckbox: 'vn-check[label="Received core VNL"]', - receivedB2BVNLCheckbox: 'vn-check[label="Received B2B VNL"]', - swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"]', - clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[field="$ctrl.client.bankEntityFk"] > div > div > div > vn-icon > i', + payMethodAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.payMethodFk"]', + IBANInput: `vn-client-billing-data ${components.vnTextfield}[name="iban"]`, + dueDayInput: `vn-client-billing-data ${components.vnInputNumber}[name="dueDay"]`, + receivedCoreLCRCheckbox: 'vn-client-billing-data vn-check[label="Received LCR"]', + receivedCoreVNLCheckbox: 'vn-client-billing-data vn-check[label="Received core VNL"]', + receivedB2BVNLCheckbox: 'vn-client-billing-data vn-check[label="Received B2B VNL"]', + swiftBicAutocomplete: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"]', + clearswiftBicButton: 'vn-client-billing-data vn-autocomplete[ng-model="$ctrl.client.bankEntityFk"] .icons > vn-icon[icon=clear]', newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button', newBankEntityName: 'vn-client-billing-data > vn-dialog vn-textfield[label="Name"] input', newBankEntityBIC: 'vn-client-billing-data > vn-dialog vn-textfield[label="Swift / BIC"] input', @@ -102,8 +102,8 @@ export default { streetAddressInput: `${components.vnTextfield}[name="street"]`, postcodeInput: `${components.vnTextfield}[name="postalCode"]`, cityInput: `${components.vnTextfield}[name="city"]`, - provinceAutocomplete: 'vn-autocomplete[field="$ctrl.address.provinceFk"]', - agencyAutocomplete: 'vn-autocomplete[field="$ctrl.address.agencyModeFk"]', + provinceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', + agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeFk"]', phoneInput: `${components.vnTextfield}[name="phone"]`, mobileInput: `${components.vnTextfield}[name="mobile"]`, defaultAddress: 'vn-client-address-index div:nth-child(1) div[name="street"]', @@ -112,10 +112,10 @@ export default { secondEditAddress: 'vn-client-address-index div:nth-child(2) > a', activeCheckbox: 'vn-check[label="Enabled"]', equalizationTaxCheckbox: 'vn-client-address-edit vn-check[label="Is equalizated"]', - firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(1) [field="observation.observationTypeFk"]', - firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(1) [model="observation.description"] input', - secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(2) [field="observation.observationTypeFk"]', - secondObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(2) [model="observation.description"] input', + firstObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(1) [ng-model="observation.observationTypeFk"]', + firstObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(1) [ng-model="observation.description"] input', + secondObservationTypeAutocomplete: 'vn-client-address-edit [name=observations] :nth-child(2) [ng-model="observation.observationTypeFk"]', + secondObservationDescriptionInput: 'vn-client-address-edit [name=observations] :nth-child(2) [ng-model="observation.description"] input', addObservationButton: 'vn-client-address-edit div[name="observations"] vn-icon-button[icon="add_circle"]', saveButton: `${components.vnSubmit}`, cancelCreateAddressButton: 'button[ui-sref="client.card.address.index"]', @@ -143,7 +143,7 @@ export default { addGreugeFloatButton: `${components.vnFloatButton}`, amountInput: `${components.vnInputNumber}[name="amount"]`, descriptionInput: `${components.vnTextfield}[name="description"]`, - typeAutocomplete: 'vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"]', + typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.greuge.greugeTypeFk"]', saveButton: `${components.vnSubmit}`, firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr' }, @@ -162,10 +162,10 @@ export default { }, clientBalance: { balanceButton: 'vn-left-menu a[ui-sref="client.card.balance.index"]', - companyAutocomplete: 'vn-client-balance-index vn-autocomplete[field="$ctrl.companyFk"]', + companyAutocomplete: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyFk"]', newPaymentButton: `${components.vnFloatButton}`, - newPaymentBank: 'vn-client-balance-create vn-autocomplete[field="$ctrl.receipt.bankFk"]', - newPaymentAmountInput: 'vn-client-balance-create vn-input-number[field="$ctrl.receipt.amountPaid"] input', + newPaymentBank: 'vn-client-balance-create vn-autocomplete[ng-model="$ctrl.receipt.bankFk"]', + newPaymentAmountInput: 'vn-client-balance-create vn-input-number[ng-model="$ctrl.receipt.amountPaid"] input', saveButton: 'vn-client-balance-create vn-button[label="Save"]', firstBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)' @@ -209,9 +209,9 @@ export default { }, itemCreateView: { temporalName: `${components.vnTextfield}[name="provisionalName"]`, - typeAutocomplete: 'vn-autocomplete[field="$ctrl.item.typeFk"]', - intrastatAutocomplete: 'vn-autocomplete[field="$ctrl.item.intrastatFk"]', - originAutocomplete: 'vn-autocomplete[field="$ctrl.item.originFk"]', + typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]', + intrastatAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]', + originAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', createButton: `${components.vnSubmit}`, cancelButton: 'button[ui-sref="item.index"]' }, @@ -219,8 +219,8 @@ export default { goBackToModuleIndexButton: 'vn-item-descriptor a[href="#!/item/index"]', moreMenu: 'vn-item-descriptor vn-icon-menu > div > vn-icon', moreMenuRegularizeButton: '.vn-popover.shown .vn-drop-down li[name="Regularize stock"]', - regularizeQuantityInput: 'vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input', - regularizeWarehouseAutocomplete: 'vn-item-descriptor vn-dialog vn-autocomplete[field="$ctrl.warehouseFk"]', + regularizeQuantityInput: 'vn-item-descriptor vn-dialog tpl-body > div > vn-textfield input', + regularizeWarehouseAutocomplete: 'vn-item-descriptor vn-dialog vn-autocomplete[ng-model="$ctrl.warehouseFk"]', editButton: 'vn-item-card vn-item-descriptor vn-float-button[icon="edit"]', regularizeSaveButton: 'vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button', inactiveIcon: 'vn-item-descriptor vn-icon[icon="icon-unavailable"]', @@ -229,13 +229,13 @@ export default { itemBasicData: { basicDataButton: 'vn-left-menu a[ui-sref="item.card.basicData"]', goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', - typeAutocomplete: 'vn-autocomplete[field="$ctrl.item.typeFk"]', - intrastatAutocomplete: 'vn-autocomplete[field="$ctrl.item.intrastatFk"]', + typeAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.typeFk"]', + intrastatAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.intrastatFk"]', nameInput: 'vn-textfield[label="Name"] input', - relevancyInput: 'vn-input-number[label="Relevancy"] input', - originAutocomplete: 'vn-autocomplete[field="$ctrl.item.originFk"]', - expenceAutocomplete: 'vn-autocomplete[field="$ctrl.item.expenceFk"]', - longNameInput: 'vn-textfield[field="$ctrl.item.longName"] input', + relevancyInput: 'vn-input-number[ng-model="$ctrl.item.relevancy"] input', + originAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.originFk"]', + expenceAutocomplete: 'vn-autocomplete[ng-model="$ctrl.item.expenceFk"]', + longNameInput: 'vn-textfield[ng-model="$ctrl.item.longName"] input', isActiveCheckbox: 'vn-check[label="Active"]', priceInKgCheckbox: 'vn-check[label="Price in kg"]', submitBasicDataButton: `${components.vnSubmit}` @@ -243,26 +243,27 @@ export default { itemTags: { goToItemIndexButton: 'vn-item-descriptor [ui-sref="item.index"]', tagsButton: 'vn-left-menu a[ui-sref="item.card.tags"]', - fourthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(4) > vn-autocomplete[field="itemTag.tagFk"]', + fourthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(4) > vn-autocomplete[ng-model="itemTag.tagFk"]', fourthValueInput: 'vn-item-tags vn-horizontal:nth-child(4) > vn-textfield[label="Value"] input', fourthRelevancyInput: 'vn-item-tags vn-horizontal:nth-child(4) > vn-textfield[label="Relevancy"] input', fourthRemoveTagButton: 'vn-item-tags vn-horizontal:nth-child(4) vn-icon-button[icon="delete"]', - fifthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(5) > vn-autocomplete[field="itemTag.tagFk"]', + fifthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(5) > vn-autocomplete[ng-model="itemTag.tagFk"]', fifthValueInput: 'vn-item-tags vn-horizontal:nth-child(5) > vn-textfield[label="Value"] input', fifthRelevancyInput: 'vn-item-tags vn-horizontal:nth-child(5) > vn-textfield[label="Relevancy"] input', - sixthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(6) > vn-autocomplete[field="itemTag.tagFk"]', + sixthTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(6) > vn-autocomplete[ng-model="itemTag.tagFk"]', sixthValueInput: 'vn-item-tags vn-horizontal:nth-child(6) > vn-textfield[label="Value"] input', sixthRelevancyInput: 'vn-item-tags vn-horizontal:nth-child(6) > vn-textfield[label="Relevancy"] input', - seventhTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(7) > vn-autocomplete[field="itemTag.tagFk"]', + seventhTagAutocomplete: 'vn-item-tags vn-horizontal:nth-child(7) > vn-autocomplete[ng-model="itemTag.tagFk"]', seventhValueInput: 'vn-item-tags vn-horizontal:nth-child(7) > vn-textfield[label="Value"] input', seventhRelevancyInput: 'vn-item-tags vn-horizontal:nth-child(7) > vn-textfield[label="Relevancy"] input', addItemTagButton: 'vn-item-tags vn-icon-button[icon="add_circle"]', submitItemTagsButton: `vn-item-tags ${components.vnSubmit}` }, itemTax: { - firstClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(1) > vn-autocomplete[field="tax.taxClassFk"]', - secondClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(2) > vn-autocomplete[field="tax.taxClassFk"]', - thirdClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(3) > vn-autocomplete[field="tax.taxClassFk"]', + undoChangesButton: 'vn-item-tax vn-button-bar > vn-button[label="Undo changes"]', + firstClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(1) > vn-autocomplete[ng-model="tax.taxClassFk"]', + secondClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(2) > vn-autocomplete[ng-model="tax.taxClassFk"]', + thirdClassAutocomplete: 'vn-item-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="tax.taxClassFk"]', submitTaxButton: `vn-item-tax ${components.vnSubmit}` }, itemBarcodes: { @@ -273,19 +274,19 @@ export default { }, itemNiches: { addNicheButton: 'vn-item-niche vn-icon[icon="add_circle"]', - firstWarehouseAutocomplete: 'vn-item-niche vn-autocomplete[field="niche.warehouseFk"]', + firstWarehouseAutocomplete: 'vn-item-niche vn-autocomplete[ng-model="niche.warehouseFk"]', firstCodeInput: 'vn-item-niche vn-horizontal:nth-child(1) > vn-textfield[label="Code"] input', - secondWarehouseAutocomplete: 'vn-item-niche vn-horizontal:nth-child(2) > vn-autocomplete[field="niche.warehouseFk"]', + secondWarehouseAutocomplete: 'vn-item-niche vn-horizontal:nth-child(2) > vn-autocomplete[ng-model="niche.warehouseFk"]', secondCodeInput: 'vn-item-niche vn-horizontal:nth-child(2) > vn-textfield[label="Code"] input', secondNicheRemoveButton: 'vn-item-niche vn-horizontal:nth-child(2) > vn-none > vn-icon-button[icon="delete"]', - thirdWarehouseAutocomplete: 'vn-item-niche vn-horizontal:nth-child(3) > vn-autocomplete[field="niche.warehouseFk"]', + thirdWarehouseAutocomplete: 'vn-item-niche vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="niche.warehouseFk"]', thirdCodeInput: 'vn-item-niche vn-horizontal:nth-child(3) > vn-textfield[label="Code"] input', submitNichesButton: `vn-item-niche ${components.vnSubmit}` }, itemBotanical: { botanicalInput: `vn-item-botanical vn-horizontal:nth-child(1) > ${components.vnTextfield}`, - genusAutocomplete: 'vn-item-botanical vn-autocomplete[field="$ctrl.botanical.genusFk"]', - speciesAutocomplete: 'vn-item-botanical vn-autocomplete[field="$ctrl.botanical.specieFk"]', + genusAutocomplete: 'vn-item-botanical vn-autocomplete[ng-model="$ctrl.botanical.genusFk"]', + speciesAutocomplete: 'vn-item-botanical vn-autocomplete[ng-model="$ctrl.botanical.specieFk"]', submitBotanicalButton: `vn-item-botanical ${components.vnSubmit}` }, itemSummary: { @@ -300,7 +301,7 @@ export default { secondTicketId: 'vn-item-diary vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(2) > span', firstBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(1) > vn-td.balance', fourthBalance: 'vn-item-diary vn-tbody > vn-tr:nth-child(4) > vn-td.balance', - warehouseAutocomplete: 'vn-item-diary vn-autocomplete[field="$ctrl.warehouseFk"]', + warehouseAutocomplete: 'vn-item-diary vn-autocomplete[ng-model="$ctrl.warehouseFk"]', }, itemLog: { anyLineCreated: 'vn-item-log > vn-log vn-tbody > vn-tr', @@ -323,31 +324,31 @@ export default { setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button' }, ticketsIndex: { - openAdvancedSearchButton: 'vn-ticket-index vn-searchbar t-right-icons > vn-icon[icon="keyboard_arrow_down"]', - advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[model="filter.refFk"] input', + openAdvancedSearchButton: 'vn-ticket-index vn-searchbar .append vn-icon[icon="arrow_drop_down"]', + advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"] input', newTicketButton: 'vn-ticket-index > a', searchResult: 'vn-ticket-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr', searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)', searchTicketInput: `vn-ticket-index ${components.vnTextfield}`, searchWeeklyTicketInput: `vn-ticket-weekly-index ${components.vnTextfield}`, - searchWeeklyClearInput: 'vn-ticket-weekly-index vn-searchbar i[class="material-icons clear"]', + searchWeeklyClearInput: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]', advancedSearchButton: 'vn-ticket-search-panel vn-submit[label="Search"] input', searchButton: 'vn-ticket-index vn-searchbar vn-icon[icon="search"]', searchWeeklyButton: 'vn-ticket-weekly-index vn-searchbar vn-icon[icon="search"]', moreMenu: 'vn-ticket-index vn-icon-menu[vn-id="more-button"] > div > vn-icon', moreMenuWeeklyTickets: '.vn-popover.shown .vn-drop-down li:nth-child(2)', - sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[field="weekly.weekDay"] input', + sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) vn-autocomplete[ng-model="weekly.weekDay"] input', weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr', firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', acceptDeleteTurn: 'vn-ticket-weekly-index > vn-confirm[vn-id="deleteWeekly"] button[response="ACCEPT"]' }, createTicketView: { - clientAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.clientFk"]', - addressAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.addressFk"]', - deliveryDateInput: 'vn-ticket-create > div > div > vn-card > div > vn-ticket-create-card > vn-date-picker > div > input', - warehouseAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.warehouseFk"]', - agencyAutocomplete: 'vn-ticket-create vn-autocomplete[field="$ctrl.ticket.agencyModeFk"]', + clientAutocomplete: 'vn-ticket-create vn-autocomplete[ng-model="$ctrl.clientFk"]', + addressAutocomplete: 'vn-ticket-create vn-autocomplete[ng-model="$ctrl.addressFk"]', + deliveryDateInput: 'vn-ticket-create vn-date-picker[ng-model="$ctrl.landed"]', + warehouseAutocomplete: 'vn-ticket-create vn-autocomplete[ng-model="$ctrl.warehouseFk"]', + agencyAutocomplete: 'vn-ticket-create vn-autocomplete[ng-model="$ctrl.ticket.agencyModeFk"]', createButton: `${components.vnSubmit}` }, ticketDescriptor: { @@ -361,7 +362,8 @@ export default { moreMenuDeleteTicket: '.vn-popover.shown .vn-drop-down li[name="Delete ticket"]', moreMenuMakeInvoice: '.vn-popover.shown .vn-drop-down li[name="Make invoice"]', moreMenuChangeShippedHour: '.vn-popover.shown .vn-drop-down li[name="Change shipped hour"]', - changeShippedHourInput: 'vn-ticket-descriptor .vn-dialog.shown vn-input-time input', + changeShippedHourDialog: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"]', + changeShippedHourInput: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"] vn-input-time[vn-id="newShipped"]', addStowawayDialogFirstTicket: 'vn-ticket-descriptor > vn-add-stowaway > vn-dialog vn-table vn-tbody vn-tr', shipButton: 'vn-ticket-descriptor > div > div.body > div.quicklinks vn-icon[icon="icon-stowaway"]', thursdayButton: 'vn-ticket-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-tool-bar > vn-button:nth-child(4)', @@ -376,7 +378,7 @@ export default { ticketNotes: { firstNoteRemoveButton: 'vn-icon[icon="delete"]', addNoteButton: 'vn-icon[icon="add_circle"]', - firstNoteTypeAutocomplete: 'vn-autocomplete[field="observation.observationTypeFk"]', + firstNoteTypeAutocomplete: 'vn-autocomplete[ng-model="observation.observationTypeFk"]', firstDescriptionInput: 'vn-textfield[label="Description"] input', submitNotesButton: `${components.vnSubmit}` }, @@ -389,10 +391,10 @@ export default { ticketPackages: { packagesButton: 'vn-left-menu a[ui-sref="ticket.card.package"]', firstPackageAutocomplete: 'vn-autocomplete[label="Package"]', - firstQuantityInput: 'vn-input-number[label="Quantity"] input', + firstQuantityInput: 'vn-input-number[ng-model="package.quantity"] input', firstRemovePackageButton: 'vn-icon-button[vn-tooltip="Remove package"]', addPackageButton: 'vn-icon-button[vn-tooltip="Add package"]', - clearPackageAutocompleteButton: 'vn-autocomplete[label="Package"] > div > div > div > vn-icon > i', + clearPackageAutocompleteButton: 'vn-autocomplete[label="Package"] .icons > vn-icon[icon=clear]', savePackagesButton: `${components.vnSubmit}` }, ticketSales: { @@ -408,7 +410,7 @@ export default { moreMenuReserve: '.vn-popover.shown .vn-drop-down li[name="Mark as reserved"]', moreMenuUnmarkReseved: '.vn-popover.shown .vn-drop-down li[name="Unmark as reserved"]', moreMenuUpdateDiscount: '.vn-popover.shown .vn-drop-down li[name="Update discount"]', - moreMenuUpdateDiscountInput: 'vn-ticket-sale vn-dialog form vn-ticket-sale-edit-discount vn-input-number[model="$ctrl.newDiscount"] input', + moreMenuUpdateDiscountInput: 'vn-ticket-sale vn-dialog form vn-ticket-sale-edit-discount vn-input-number[ng-model="$ctrl.newDiscount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', firstSaleClaimIcon: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(1) vn-icon[icon="icon-claims"]', @@ -416,11 +418,11 @@ export default { firstSaleText: 'vn-table div > vn-tbody > vn-tr:nth-child(1)', firstSaleThumbnailImage: 'vn-ticket-sale:nth-child(1) vn-tr:nth-child(1) vn-td:nth-child(3) > img', firstSaleZoomedImage: 'body > div > div > img', - firstSaleQuantity: 'vn-input-number[model="sale.quantity"]:nth-child(1) input', + firstSaleQuantity: 'vn-input-number[ng-model="sale.quantity"]:nth-child(1) input', firstSaleQuantityCell: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td-editable:nth-child(5)', - firstSaleQuantityClearInput: 'vn-textfield[model="sale.quantity"] div.suffix > i', - firstSaleIdInput: 'body > vn-app > div > ui-view > vn-ticket-card > vn-main-block > div > vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > vn-autocomplete > div > div > input', - firstSaleIdAutocomplete: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > vn-autocomplete', + firstSaleQuantityClearInput: 'vn-textfield[ng-model="sale.quantity"] div.suffix > i', + firstSaleIdInput: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > vn-autocomplete input', + firstSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > vn-autocomplete', idAutocompleteFirstResult: '.vn-popover.shown .vn-drop-down li', firstSalePrice: 'vn-ticket-sale vn-table vn-tr:nth-child(1) > vn-td:nth-child(7) > span', firstSalePriceInput: '.vn-popover.shown vn-input-number input', @@ -428,9 +430,9 @@ export default { firstSaleDiscountInput: 'vn-ticket-sale:nth-child(1) vn-ticket-sale-edit-discount vn-input-number input', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(9)', firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', - firstSaleColour: 'vn-tr:nth-child(1) vn-fetched-tags section', + firstSaleColour: 'vn-ticket-sale vn-tr:nth-child(1) vn-fetched-tags section', firstSaleLength: 'vn-ticket-sale vn-tr:nth-child(1) vn-td-editable:nth-child(6) section:nth-child(3)', - firstSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"]', + firstSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(1) vn-check[ng-model="sale.checked"]', secondSaleColour: 'vn-tr:nth-child(2) vn-fetched-tags section', secondSalePrice: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(7) > span', secondSaleDiscount: 'vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(8)', @@ -438,18 +440,18 @@ export default { secondSaleText: 'vn-table div > vn-tbody > vn-tr:nth-child(2)', secondSaleId: 'vn-ticket-sale:nth-child(2) vn-td-editable:nth-child(4) text > span', secondSaleIdCell: 'vn-ticket-sale vn-tr:nth-child(2) > vn-td-editable:nth-child(4)', - secondSaleIdInput: 'body > vn-app > div > ui-view > vn-ticket-card > vn-main-block > div > vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete > div > div > input', - secondSaleIdAutocomplete: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete', + secondSaleIdInput: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete input', + secondSaleIdAutocomplete: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(4) > vn-autocomplete', secondSaleQuantity: 'vn-ticket-sale vn-table vn-tr:nth-child(2) vn-input-number input', - secondSaleConceptCell: 'vn-ticket-sale vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)', + secondSaleConceptCell: 'vn-ticket-sale vn-table vn-tbody > vn-tr:nth-child(2) > vn-td-editable:nth-child(6)', secondSaleConceptInput: 'vn-ticket-sale vn-table vn-tr:nth-child(2) > vn-td-editable.ng-isolate-scope.selected vn-textfield input', totalImport: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > vn-one > p:nth-child(3) > strong', selectAllSalesCheckbox: 'vn-ticket-sale vn-thead vn-check', - secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[field="sale.checked"]', - thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[field="sale.checked"]', + secondSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(2) vn-check[ng-model="sale.checked"]', + thirdSaleCheckbox: 'vn-ticket-sale vn-tr:nth-child(3) vn-check[ng-model="sale.checked"]', deleteSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="delete"]', transferSaleButton: 'vn-ticket-sale vn-tool-bar > vn-button[icon="call_split"]', - moveToTicketInput: '.vn-popover.shown vn-textfield[model="$ctrl.transfer.ticketId"] input', + moveToTicketInput: '.vn-popover.shown vn-textfield[ng-model="$ctrl.transfer.ticketId"] input', moveToTicketInputClearButton: '.vn-popover.shown i[title="Clear"]', moveToTicketButton: '.vn-popover.shown vn-icon[icon="arrow_forward_ios"]', moveToNewTicketButton: '.vn-popover.shown vn-button[label="New ticket"]', @@ -460,36 +462,34 @@ export default { ticketTracking: { trackingButton: 'vn-left-menu a[ui-sref="ticket.card.tracking.index"]', createStateButton: `${components.vnFloatButton}`, - stateAutocomplete: 'vn-ticket-tracking-edit vn-autocomplete[field="$ctrl.stateFk"]', + stateAutocomplete: 'vn-ticket-tracking-edit vn-autocomplete[ng-model="$ctrl.stateFk"]', saveButton: `${components.vnSubmit}`, cancelButton: 'vn-ticket-tracking-edit vn-button[ui-sref="ticket.card.tracking.index"]' }, ticketBasicData: { basicDataButton: 'vn-left-menu a[ui-sref="ticket.card.basicData.stepOne"]', - clientAutocomplete: 'vn-autocomplete[field="$ctrl.clientFk"]', - addressAutocomplete: 'vn-autocomplete[field="$ctrl.ticket.addressFk"]', - agencyAutocomplete: 'vn-autocomplete[field="$ctrl.agencyModeId"]', - zoneAutocomplete: 'vn-autocomplete[field="$ctrl.zoneId"]', + clientAutocomplete: 'vn-autocomplete[ng-model="$ctrl.clientFk"]', + addressAutocomplete: 'vn-autocomplete[ng-model="$ctrl.ticket.addressFk"]', + agencyAutocomplete: 'vn-autocomplete[ng-model="$ctrl.agencyModeId"]', + zoneAutocomplete: 'vn-autocomplete[ng-model="$ctrl.zoneId"]', nextStepButton: 'vn-step-control > section > section.buttons > section:nth-child(2) > vn-button', finalizeButton: 'vn-step-control > section > section.buttons > section:nth-child(2) > vn-submit', stepTwoTotalPriceDif: 'vn-ticket-basic-data-step-two > form > vn-card > div > vn-horizontal > table > tfoot > tr > td:nth-child(4)', - chargesReasonAutocomplete: 'vn-autocomplete[field="$ctrl.ticket.option"]', + chargesReasonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.ticket.option"]', }, ticketComponents: { - base: 'vn-ticket-components tfoot > tr:nth-child(1) > td', - margin: 'vn-ticket-components tfoot > tr:nth-child(2) > td', - total: 'vn-ticket-components tfoot > tr:nth-child(3) > td' + base: 'vn-ticket-components [name="base-sum"]' }, ticketRequests: { addRequestButton: 'vn-ticket-request-index > a > vn-float-button > button', - request: 'vn-ticket-request-index > form > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr', - descriptionInput: 'vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-textfield > div > div > div.infix > input', - atenderAutocomplete: 'vn-ticket-request-create vn-autocomplete[field="$ctrl.ticketRequest.atenderFk"]', - quantityInput: 'vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-input-number:nth-child(1) > div > div > div.infix > input', - priceInput: 'vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(2) > vn-input-number:nth-child(2) > div > div > div.infix > input', + request: 'vn-ticket-request-index vn-table vn-tr', + descriptionInput: 'vn-ticket-request-create > form > div > vn-card > div > vn-horizontal:nth-child(1) > vn-textfield input', + atenderAutocomplete: 'vn-ticket-request-create vn-autocomplete[ng-model="$ctrl.ticketRequest.atenderFk"]', + quantityInput: 'vn-ticket-request-create vn-input-number input[name=quantity]', + priceInput: 'vn-ticket-request-create vn-input-number input[name=price]', firstRemoveRequestButton: 'vn-ticket-request-index vn-icon[icon="delete"]:nth-child(1)', saveButton: 'vn-ticket-request-create > form > div > vn-button-bar > vn-submit[label="Create"] input', - firstDescription: 'vn-ticket-request-index > form > vn-card > div > vn-horizontal > vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2)', + firstDescription: 'vn-ticket-request-index vn-table vn-tr:nth-child(1) > vn-td:nth-child(2)', }, ticketLog: { @@ -501,20 +501,20 @@ export default { ticketService: { addServiceButton: 'vn-ticket-service vn-icon-button[vn-tooltip="Add service"] > button', firstAddDescriptionButton: 'vn-ticket-service vn-icon-button[vn-tooltip="New service type"] > button', - firstDescriptionAutocomplete: 'vn-ticket-service vn-autocomplete[field="service.description"]', + firstDescriptionAutocomplete: 'vn-ticket-service vn-autocomplete[ng-model="service.description"]', firstQuantityInput: 'vn-ticket-service vn-input-number[label="Quantity"] input', firstPriceInput: 'vn-ticket-service vn-input-number[label="Price"] input', firstVatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]', - fistDeleteServiceButton: 'vn-ticket-card > vn-main-block > div.content-block.ng-scope > vn-ticket-service > form > vn-card > div > vn-one:nth-child(1) > vn-horizontal:nth-child(1) > vn-auto > vn-icon-button[icon="delete"]', - newDescriptionInput: 'vn-ticket-service > vn-dialog vn-textfield[model="$ctrl.newServiceType.name"] input', + fistDeleteServiceButton: 'vn-ticket-service form vn-horizontal:nth-child(1) vn-icon-button[icon="delete"]', + newDescriptionInput: 'vn-ticket-service > vn-dialog vn-textfield[ng-model="$ctrl.newServiceType.name"] input', serviceLine: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal', saveServiceButton: `${components.vnSubmit}`, saveDescriptionButton: 'vn-ticket-service > vn-dialog[vn-id="createServiceTypeDialog"] > div > form > div.buttons > tpl-buttons > button' }, createStateView: { - stateAutocomplete: 'vn-autocomplete[field="$ctrl.stateFk"]', - workerAutocomplete: 'vn-autocomplete[field="$ctrl.workerFk"]', - clearStateInputButton: 'vn-autocomplete[field="$ctrl.stateFk"] > div > div > div > vn-icon > i', + stateAutocomplete: 'vn-autocomplete[ng-model="$ctrl.stateFk"]', + workerAutocomplete: 'vn-autocomplete[ng-model="$ctrl.workerFk"]', + clearStateInputButton: 'vn-autocomplete[ng-model="$ctrl.stateFk"] .icons > vn-icon[icon=clear]', saveStateButton: `${components.vnSubmit}` }, claimsIndex: { @@ -530,7 +530,7 @@ export default { claimSummary: { header: 'vn-claim-summary > vn-card > div > h5', state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-textarea[model="$ctrl.summary.claim.observation"] > div > textarea', + observation: 'vn-claim-summary vn-textarea[ng-model="$ctrl.summary.claim.observation"] textarea', firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(4) > vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', @@ -541,45 +541,45 @@ export default { firstActionTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor' }, claimBasicData: { - claimStateAutocomplete: 'vn-claim-basic-data vn-autocomplete[field="$ctrl.claim.claimStateFk"]', + claimStateAutocomplete: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', responsabilityInputRange: 'vn-input-range', - observationInput: 'vn-textarea[field="$ctrl.claim.observation"] textarea', + observationInput: 'vn-textarea[ng-model="$ctrl.claim.observation"] textarea', saveButton: `${components.vnSubmit}` }, claimDetail: { secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(6) > span', - discountInput: '.vn-popover.shown vn-input-number[model="$ctrl.newDiscount"] > div > div > div.infix > input', + discountInput: '.vn-popover.shown vn-input-number[ng-model="$ctrl.newDiscount"] input', discoutPopoverMana: '.vn-popover.shown .content > div > vn-horizontal > h5', addItemButton: 'vn-claim-detail a vn-float-button', firstClaimableSaleFromTicket: 'vn-claim-detail > vn-dialog vn-tbody > vn-tr', claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr', - firstItemQuantityInput: 'vn-claim-detail vn-tr:nth-child(1) vn-input-number[model="saleClaimed.quantity"] input', + firstItemQuantityInput: 'vn-claim-detail vn-tr:nth-child(1) vn-input-number[ng-model="saleClaimed.quantity"] input', totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span', secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(8) > vn-icon-button > button > vn-icon > i' }, claimDevelopment: { addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > vn-one > vn-icon-button > button > vn-icon', firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > div > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon', - firstClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[field="claimDevelopment.claimReasonFk"]', - firstClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[field="claimDevelopment.claimResultFk"]', - firstClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[field="claimDevelopment.claimResponsibleFk"]', - firstClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[field="claimDevelopment.workerFk"]', - firstClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', - secondClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimReasonFk"]', - secondClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimResultFk"]', - secondClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimResponsibleFk"]', - secondClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.workerFk"]', - secondClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[field="claimDevelopment.claimRedeliveryFk"]', + firstClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', + firstClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', + firstClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', + firstClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.workerFk"]', + firstClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', + secondClaimReasonAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', + secondClaimResultAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', + secondClaimResponsibleAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', + secondClaimWorkerAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.workerFk"]', + secondClaimRedeliveryAutocomplete: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', saveDevelopmentButton: `${components.vnSubmit}` }, claimAction: { importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', importTicketButton: 'vn-claim-action vn-button[label="Import ticket"]', secondImportableTicket: '.vn-popover.shown .content > div > vn-table > div > vn-tbody > vn-tr:nth-child(2)', - firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', - secondLineDestination: 'vn-claim-action vn-tr:nth-child(2) vn-autocomplete[field="saleClaimed.claimDestinationFk"]', + firstLineDestination: 'vn-claim-action vn-tr:nth-child(1) vn-autocomplete[ng-model="saleClaimed.claimDestinationFk"]', + secondLineDestination: 'vn-claim-action vn-tr:nth-child(2) vn-autocomplete[ng-model="saleClaimed.claimDestinationFk"]', firstDeleteLine: 'vn-claim-action vn-tr:nth-child(1) vn-icon-button[icon="delete"]', - isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"]' + isPaidWithManaCheckbox: 'vn-check[ng-model="$ctrl.claim.isChargedToMana"]' }, ordersIndex: { searchResult: 'vn-order-index vn-card > div > vn-table > div > vn-tbody > a.vn-tr', @@ -597,7 +597,7 @@ export default { clientAutocomplete: 'vn-autocomplete[label="Client"]', addressAutocomplete: 'vn-autocomplete[label="Address"]', agencyAutocomplete: 'vn-autocomplete[label="Agency"]', - landedDatePicker: 'vn-date-picker[label="Landed"] input', + landedDatePicker: 'vn-date-picker[label="Landed"]', createButton: `${components.vnSubmit}`, cancelButton: 'vn-button[href="#!/client/index"]' }, @@ -605,14 +605,14 @@ export default { orderByAutocomplete: 'vn-autocomplete[label="Order by"]', plantRealmButton: 'vn-order-catalog > vn-side-menu vn-icon[icon="icon-plant"]', typeAutocomplete: 'vn-autocomplete[data="$ctrl.itemTypes"]', - itemIdInput: 'vn-order-catalog > vn-side-menu vn-catalog-filter vn-textfield[model="$ctrl.itemFk"] input', - itemTagValueInput: 'vn-order-catalog > vn-side-menu vn-catalog-filter vn-textfield[model="$ctrl.value"] input', - openTagSearch: 'vn-order-catalog > vn-side-menu > div > vn-catalog-filter > div > vn-vertical > vn-textfield[model="$ctrl.value"] > div > div > div.rightIcons > t-right-icons > i', - tagAutocomplete: 'vn-order-catalog-search-panel vn-autocomplete[field="filter.tagFk"]', - tagValueInput: 'vn-order-catalog-search-panel vn-textfield[model="filter.value"] input', + itemIdInput: 'vn-catalog-filter vn-textfield[ng-model="$ctrl.itemFk"] input', + itemTagValueInput: 'vn-catalog-filter vn-textfield[ng-model="$ctrl.value"] input', + openTagSearch: 'vn-catalog-filter > div > vn-vertical > vn-textfield[ng-model="$ctrl.value"] .append i', + tagAutocomplete: 'vn-order-catalog-search-panel vn-autocomplete[ng-model="filter.tagFk"]', + tagValueInput: 'vn-order-catalog-search-panel vn-textfield[ng-model="filter.value"] input', searchTagButton: 'vn-order-catalog-search-panel > div > form > vn-horizontal:nth-child(3) > vn-submit > input', - thirdFilterRemoveButton: 'vn-order-catalog > vn-side-menu vn-catalog-filter > div > vn-horizontal.chips > vn-chip:nth-child(3) button', - fourthFilterRemoveButton: 'vn-order-catalog > vn-side-menu vn-catalog-filter > div > vn-horizontal.chips > vn-chip:nth-child(4) button', + thirdFilterRemoveButton: 'vn-catalog-filter > div > vn-horizontal.chips > vn-chip:nth-child(3) button', + fourthFilterRemoveButton: 'vn-catalog-filter > div > vn-horizontal.chips > vn-chip:nth-child(4) button', }, orderBasicData: { clientAutocomplete: 'vn-autocomplete[label="Client"]', @@ -632,11 +632,11 @@ export default { addNewRouteButton: 'vn-route-index > a[ui-sref="route.create"]' }, createRouteView: { - workerAutocomplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.workerFk"]', - createdDatePicker: 'vn-route-create vn-date-picker[model="$ctrl.route.created"] > div > input', - vehicleAutoComplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.vehicleFk"]', - agencyAutoComplete: 'vn-route-create vn-autocomplete[field="$ctrl.route.agencyModeFk"]', - descriptionInput: 'vn-route-create vn-textfield[field="$ctrl.route.description"] input', + workerAutocomplete: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.workerFk"]', + createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.created"]', + vehicleAutoComplete: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]', + agencyAutoComplete: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]', + descriptionInput: 'vn-route-create vn-textfield[ng-model="$ctrl.route.description"] input', submitButton: 'vn-route-create vn-submit > input[type="submit"]' }, routeDescriptor: { @@ -646,29 +646,29 @@ export default { routeId: 'vn-route-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(1) > section > span' }, routeBasicData: { - workerAutoComplete: 'vn-route-basic-data vn-autocomplete[field="$ctrl.route.workerFk"]', - vehicleAutoComplete: 'vn-route-basic-data vn-autocomplete[field="$ctrl.route.vehicleFk"]', - agencyAutoComplete: 'vn-route-basic-data vn-autocomplete[field="$ctrl.route.agencyModeFk"]', - kmStartInput: 'vn-route-basic-data vn-input-number[field="$ctrl.route.kmStart"] input', - kmEndInput: 'vn-route-basic-data vn-input-number[model="$ctrl.route.kmEnd"] input', - createdDateInput: 'vn-route-basic-data vn-date-picker[model="$ctrl.route.created"] > div > input', - startedHourInput: 'vn-route-basic-data vn-input-time[model="$ctrl.route.started"] input', - finishedHourInput: 'vn-route-basic-data vn-input-time[model="$ctrl.route.finished"] input', + workerAutoComplete: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.workerFk"]', + vehicleAutoComplete: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]', + agencyAutoComplete: 'vn-route-basic-data vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]', + kmStartInput: 'vn-route-basic-data vn-input-number[ng-model="$ctrl.route.kmStart"] input', + kmEndInput: 'vn-route-basic-data vn-input-number[ng-model="$ctrl.route.kmEnd"] input', + createdDateInput: 'vn-route-basic-data vn-date-picker[ng-model="$ctrl.route.created"]', + startedHourInput: 'vn-route-basic-data vn-input-time[ng-model="$ctrl.route.started"] input', + finishedHourInput: 'vn-route-basic-data vn-input-time[ng-model="$ctrl.route.finished"] input', saveButton: 'vn-route-basic-data vn-submit[label="Save"] input' }, routeTickets: { - firstTicketPriority: 'vn-route-tickets vn-tr:nth-child(1) vn-textfield[model="ticket.priority"] input', - secondTicketPriority: 'vn-route-tickets vn-tr:nth-child(2) vn-textfield[model="ticket.priority"] input', - thirdTicketPriority: 'vn-route-tickets vn-tr:nth-child(3) vn-textfield[model="ticket.priority"] input', - fourthTicketPriority: 'vn-route-tickets vn-tr:nth-child(4) vn-textfield[model="ticket.priority"] input', - eleventhTicketPriority: 'vn-route-tickets vn-tr:nth-child(11) vn-textfield[model="ticket.priority"] input', + firstTicketPriority: 'vn-route-tickets vn-tr:nth-child(1) vn-textfield[ng-model="ticket.priority"] input', + secondTicketPriority: 'vn-route-tickets vn-tr:nth-child(2) vn-textfield[ng-model="ticket.priority"] input', + thirdTicketPriority: 'vn-route-tickets vn-tr:nth-child(3) vn-textfield[ng-model="ticket.priority"] input', + fourthTicketPriority: 'vn-route-tickets vn-tr:nth-child(4) vn-textfield[ng-model="ticket.priority"] input', + eleventhTicketPriority: 'vn-route-tickets vn-tr:nth-child(11) vn-textfield[ng-model="ticket.priority"] input', firstTicketCheckbox: 'vn-route-tickets vn-tr:nth-child(1) vn-check', buscamanButton: 'vn-route-tickets vn-button[icon="icon-buscaman"]', firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]', confirmButton: 'vn-route-tickets > vn-confirm button[response="ACCEPT"]' }, workerPbx: { - extensionInput: 'vn-worker-pbx vn-textfield[model="$ctrl.worker.sip.extension"] input', + extensionInput: 'vn-worker-pbx vn-textfield[ng-model="$ctrl.worker.sip.extension"] input', saveButton: 'vn-worker-pbx vn-submit[label="Save"] input' }, workerTimeControl: { diff --git a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js index a4c97eb62..52e2db237 100644 --- a/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/02-client-module/12_lock_of_verified_data.spec.js @@ -176,7 +176,7 @@ describe('Client lock verified data path', () => { .wait(selectors.clientFiscalData.socialNameInput) .evaluate(selector => { return document.querySelector(selector).disabled; - }, 'vn-textfield[model="$ctrl.client.socialName"] > div'); + }, 'vn-textfield[ng-model="$ctrl.client.socialName"] > div'); expect(result).toBeFalsy(); }); diff --git a/e2e/paths/04-item-module/03_tax.spec.js b/e2e/paths/04-item-module/03_tax.spec.js index 38861f1bf..903d05f10 100644 --- a/e2e/paths/04-item-module/03_tax.spec.js +++ b/e2e/paths/04-item-module/03_tax.spec.js @@ -1,8 +1,7 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -// #1702 Autocomplete no siempre refresca al cancelar formulario -xdescribe('Item edit tax path', () => { +describe('Item edit tax path', () => { const nightmare = createNightmare(); beforeAll(() => { @@ -14,9 +13,9 @@ xdescribe('Item edit tax path', () => { it(`should add the item tax to all countries`, async() => { const result = await nightmare - .autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'Reduced VAT') + .autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'General VAT') .autocompleteSearch(selectors.itemTax.secondClassAutocomplete, 'General VAT') - .autocompleteSearch(selectors.itemTax.thirdClassAutocomplete, 'Reduced VAT') + .autocompleteSearch(selectors.itemTax.thirdClassAutocomplete, 'General VAT') .waitToClick(selectors.itemTax.submitTaxButton) .waitForLastSnackbar(); @@ -28,7 +27,7 @@ xdescribe('Item edit tax path', () => { .reloadSection('item.card.tax') .waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value'); - expect(firstVatType).toEqual('Reduced VAT'); + expect(firstVatType).toEqual('General VAT'); }); it(`should confirm the second item tax class was edited`, async() => { @@ -42,6 +41,22 @@ xdescribe('Item edit tax path', () => { const thirdVatType = await nightmare .waitToGetProperty(`${selectors.itemTax.thirdClassAutocomplete} input`, 'value'); - expect(thirdVatType).toEqual('Reduced VAT'); + expect(thirdVatType).toEqual('General VAT'); + }); + + it(`should edit the first class without saving the form`, async() => { + const firstVatType = await nightmare + .autocompleteSearch(selectors.itemTax.firstClassAutocomplete, 'Reduced VAT') + .waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value'); + + expect(firstVatType).toEqual('Reduced VAT'); + }); + + it(`should now click the undo changes button and see the changes works`, async() => { + const firstVatType = await nightmare + .waitToClick(selectors.itemTax.undoChangesButton) + .waitToGetProperty(`${selectors.itemTax.firstClassAutocomplete} input`, 'value'); + + expect(firstVatType).toEqual('General VAT'); }); }); diff --git a/e2e/paths/05-ticket-module/09_weekly.spec.js b/e2e/paths/05-ticket-module/09_weekly.spec.js index bba4a20e7..a7a301d79 100644 --- a/e2e/paths/05-ticket-module/09_weekly.spec.js +++ b/e2e/paths/05-ticket-module/09_weekly.spec.js @@ -160,7 +160,7 @@ describe('Ticket descriptor path', () => { it('should confirm the sixth weekly ticket was deleted', async() => { const result = await nightmare - .waitToClick('vn-ticket-weekly-index vn-searchbar i[class="material-icons clear"]') + .waitToClick('vn-ticket-weekly-index vn-searchbar vn-icon[icon=clear]') .waitToClick(selectors.ticketsIndex.searchWeeklyButton) .waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5) .countElement(selectors.ticketsIndex.searchWeeklyResult); diff --git a/e2e/paths/05-ticket-module/12_descriptor.spec.js b/e2e/paths/05-ticket-module/12_descriptor.spec.js index c178e7fc8..5c80bbfe8 100644 --- a/e2e/paths/05-ticket-module/12_descriptor.spec.js +++ b/e2e/paths/05-ticket-module/12_descriptor.spec.js @@ -30,20 +30,11 @@ describe('Ticket descriptor path', () => { expect(url.hash).toContain('/summary'); }); - it('should open the change shipped hours dialog by using the more menu option', async() => { - const visible = await nightmare + it(`should update the shipped hour using the descriptor menu`, async() => { + const result = await nightmare .waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour) - .wait(selectors.ticketDescriptor.changeShippedHourInput) - .isVisible(selectors.ticketDescriptor.changeShippedHourInput); - - - expect(visible).toBeTruthy(); - }); - - it(`should update the shipped hour`, async() => { - const result = await nightmare - .pickTime(selectors.ticketDescriptor.changeShippedHourInput, '08:15') + .write(selectors.ticketDescriptor.changeShippedHourInput, '08:15') .waitToClick(selectors.ticketDescriptor.acceptChangeHourButton) .waitForLastSnackbar(); @@ -127,16 +118,6 @@ describe('Ticket descriptor path', () => { expect(result).toEqual('Data saved!'); }); - it(`should navigate to the added ticket using the descriptors ship button`, async() => { - const url = await nightmare - .waitToClick(selectors.ticketDescriptor.closeStowawayDialog) - .waitToClick(selectors.ticketDescriptor.shipButton) - .waitForURL('#!/ticket/17/summary') - .parsedUrl(); - - expect(url.hash).toContain('#!/ticket/17/summary'); - }); - it(`should check the state of the stowaway ticket is embarked`, async() => { const state = await nightmare .waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText'); @@ -144,15 +125,6 @@ describe('Ticket descriptor path', () => { expect(state).toEqual('State Embarcando'); }); - it(`should navigate to the ship ticket using the descriptors ship button`, async() => { - const url = await nightmare - .waitToClick(selectors.ticketDescriptor.shipButton) - .waitForURL('#!/ticket/16/summary') - .parsedUrl(); - - expect(url.hash).toContain('#!/ticket/16/summary'); - }); - it(`should navigate back to the added ticket using the descriptors ship button`, async() => { const url = await nightmare .waitToClick(selectors.ticketDescriptor.closeStowawayDialog) diff --git a/e2e/paths/08-route-module/03_tickets.spec.js b/e2e/paths/08-route-module/03_tickets.spec.js index c1a0350b3..24a3ebbcf 100644 --- a/e2e/paths/08-route-module/03_tickets.spec.js +++ b/e2e/paths/08-route-module/03_tickets.spec.js @@ -49,7 +49,7 @@ xdescribe('Route basic Data path', () => { it('should count how many tickets are in route', async() => { const result = await nightmare - .countElement('vn-route-tickets vn-textfield[model="ticket.priority"]'); + .countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]'); expect(result).toEqual(11); }); @@ -74,7 +74,7 @@ xdescribe('Route basic Data path', () => { it('should now count how many tickets are in route to find one less', async() => { const result = await nightmare - .countElement('vn-route-tickets vn-textfield[model="ticket.priority"]'); + .countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]'); expect(result).toEqual(9); }); diff --git a/front/core/components/autocomplete/autocomplete.html b/front/core/components/autocomplete/autocomplete.html deleted file mode 100755 index 4caca44bc..000000000 --- a/front/core/components/autocomplete/autocomplete.html +++ /dev/null @@ -1,27 +0,0 @@ -
-
- -
- - -
- -
-
- - \ No newline at end of file diff --git a/front/core/components/autocomplete/index.html b/front/core/components/autocomplete/index.html new file mode 100755 index 000000000..2e5cc39f6 --- /dev/null +++ b/front/core/components/autocomplete/index.html @@ -0,0 +1,52 @@ +
+
+
+
+
+
+ + +
+
+ +
+
+ + + + +
+
+
+
+ + +
+
+
+
+
+ + \ No newline at end of file diff --git a/front/core/components/autocomplete/autocomplete.js b/front/core/components/autocomplete/index.js similarity index 77% rename from front/core/components/autocomplete/autocomplete.js rename to front/core/components/autocomplete/index.js index 469bb9e93..69114d028 100755 --- a/front/core/components/autocomplete/autocomplete.js +++ b/front/core/components/autocomplete/index.js @@ -1,5 +1,5 @@ import ngModule from '../../module'; -import Input from '../../lib/input'; +import Field from '../field'; import assignProps from '../../lib/assign-props'; import {mergeWhere} from 'vn-loopback/util/filter'; import './style.scss'; @@ -16,23 +16,18 @@ import './style.scss'; * * @event change Thrown when value is changed */ -export default class Autocomplete extends Input { - constructor($element, $scope, $http, $transclude, $translate, $interpolate) { - super($element, $scope); - this.$http = $http; - this.$interpolate = $interpolate; - this.$transclude = $transclude; - this.$translate = $translate; - this._field = undefined; +export default class Autocomplete extends Field { + constructor($element, $scope, $compile, $http, $transclude, $translate, $interpolate) { + super($element, $scope, $compile); + Object.assign(this, { + $http, + $interpolate, + $transclude, + $translate + }); + this._selection = null; - this.readonly = true; - this.form = null; - this.input = this.element.querySelector('.mdl-textfield__input'); - - componentHandler.upgradeElement( - this.element.querySelector('.mdl-textfield')); - - this.registerEvents(); + this.input = this.element.querySelector('input'); } $postLink() { @@ -44,12 +39,16 @@ export default class Autocomplete extends Input { } /** - * Registers all event emitters + * @type {any} The autocomplete value. */ - registerEvents() { - this.input.addEventListener('focus', event => { - this.emit('focus', {event}); - }); + get field() { + return super.field; + } + + set field(value) { + super.field = value; + this.refreshSelection(); + this.emit('change', {value}); } get model() { @@ -83,20 +82,6 @@ export default class Autocomplete extends Input { Object.assign(this.$.dropDown, props); } - /** - * @type {any} The autocomplete value. - */ - get field() { - return this._field; - } - - set field(value) { - this._field = value; - - this.refreshSelection(); - this.emit('change', {value}); - } - /** * @type {Object} The selected data object, you can use this property * to prevent requests to display the initial value. @@ -136,8 +121,8 @@ export default class Autocomplete extends Input { return; const selection = this.fetchSelection(); - if (!this.selection) - this.selection = selection; + + this.selection = selection; } fetchSelection() { @@ -216,39 +201,21 @@ export default class Autocomplete extends Input { if (this.translateFields.indexOf(this.showField) > -1) this.input.value = this.$translate.instant(display); } - - this.mdlUpdate(); - } - - mdlUpdate() { - let field = this.element.querySelector('.mdl-textfield'); - let mdlField = field.MaterialTextfield; - if (mdlField) mdlField.updateClasses_(); - } - - setValue(value) { - this.field = value; - if (this.form) this.form.$setDirty(); } onDropDownSelect(item) { const value = item[this.valueField]; this.selection = item; - this.setValue(value); + this.field = value; } - onClearClick(event) { - event.preventDefault(); - this.setValue(null); - } + onContainerKeyDown(event) { + if (event.defaultPrevented) return; - onKeyDown(event) { - // if (event.defaultPrevented) return; - - switch (event.keyCode) { - case 38: // Up - case 40: // Down - case 13: // Enter + switch (event.code) { + case 'ArrowUp': + case 'ArrowDown': + case 'Enter': this.showDropDown(); break; default: @@ -261,7 +228,8 @@ export default class Autocomplete extends Input { event.preventDefault(); } - onMouseDown(event) { + onContainerMouseDown(event) { + if (event.defaultPrevented) return; event.preventDefault(); this.showDropDown(); } @@ -293,7 +261,7 @@ export default class Autocomplete extends Input { showDropDown(search) { this.assignDropdownProps(); - this.$.dropDown.show(this.input, search); + this.$.dropDown.show(this.container, search); } get fetchFunction() { @@ -307,16 +275,12 @@ export default class Autocomplete extends Input { this.refreshSelection(); } } -Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate', '$interpolate']; +Autocomplete.$inject = ['$element', '$scope', '$compile', '$http', '$transclude', '$translate', '$interpolate']; -ngModule.component('vnAutocomplete', { - template: require('./autocomplete.html'), +ngModule.vnComponent('vnAutocomplete', { + template: require('./index.html'), controller: Autocomplete, bindings: { - label: '@', - field: '=?', - disabled: ' div > .mdl-textfield { - position: relative; - width: 100%; + & > .container { + cursor: pointer; - & > input { - cursor: pointer; - height: 30px; - text-overflow: ellipsis; - white-space: nowrap; + & > .infix > .control { overflow: hidden; - } - & > .icons { - display: none; - position: absolute; - right: 0; - top: 1.3em; - height: 1em; - color: $color-font-secondary; - border-radius: .2em; - - & > vn-icon { + + & > input { cursor: pointer; - font-size: 18px; - - &:hover { - color: $color-font; - } + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + text-align: left; + padding-left: 0; + padding-right: 0; } } - &:hover > .icons, - & > input:focus + .icons { - display: block; - } - } - - label span:nth-child(2) { - color: $color-alert } } - -ul.vn-autocomplete { - list-style-type: none; - padding: 1em; - margin: 0; - padding: 0; - overflow: auto; - max-height: 300px; - - li { - @extend %clickable; - display: block; - padding: .8em; - margin: 0; - - &.load-more { - color: $color-main; - font-family: vn-font-bold; - padding: .4em .8em; - } - } -} \ No newline at end of file diff --git a/front/core/components/check/index.js b/front/core/components/check/index.js index 35ff07e8a..b9bd1bb2f 100644 --- a/front/core/components/check/index.js +++ b/front/core/components/check/index.js @@ -12,13 +12,13 @@ import './style.scss'; */ export default class Check extends Toggle { set field(value) { - this._field = value; + super.field = value; this.element.classList.toggle('checked', Boolean(value)); this.indeterminate = Boolean(value == null && this.tripleState); } get field() { - return this._field; + return super.field; } set checked(value) { @@ -64,14 +64,10 @@ export default class Check extends Toggle { } } -ngModule.component('vnCheck', { +ngModule.vnComponent('vnCheck', { template: require('./index.html'), controller: Check, bindings: { - label: '@?', - field: '=?', - disabled: ' { })); beforeEach(inject(($compile, $rootScope) => { - $element = $compile(``)($rootScope); $ctrl = $element.controller('vnCheck'); element = $element[0]; })); diff --git a/front/core/components/date-picker/date-picker.html b/front/core/components/date-picker/date-picker.html deleted file mode 100644 index 67fcd880b..000000000 --- a/front/core/components/date-picker/date-picker.html +++ /dev/null @@ -1,21 +0,0 @@ -
- -
- - clear - -
- -
\ No newline at end of file diff --git a/front/core/components/date-picker/date-picker.js b/front/core/components/date-picker/date-picker.js deleted file mode 100644 index 1156ab09a..000000000 --- a/front/core/components/date-picker/date-picker.js +++ /dev/null @@ -1,107 +0,0 @@ -import ngModule from '../../module'; -import Component from '../../lib/component'; -import {Flatpickr} from '../../vendor'; -import './style.scss'; - -class DatePicker extends Component { - constructor($element, $scope, $translate, $attrs) { - super($element, $scope); - this.input = $element[0].querySelector('input'); - this.$translate = $translate; - this.$attrs = $attrs; - this._model = undefined; - this.dateValue = undefined; - this.hasMouseIn = false; - let locale = this.$translate.use(); - this.defaultOptions = { - locale: locale, - dateFormat: locale == 'es' ? 'd-m-Y' : 'Y-m-d', - enableTime: false, - disableMobile: true, - onValueUpdate: () => this.onValueUpdate() - }; - this.userOptions = {}; - this._iniOptions = this.defaultOptions; - componentHandler.upgradeElement($element[0].firstChild); - this.vp = new Flatpickr(this.input, this._iniOptions); - } - - onValueUpdate() { - if (this.vp.selectedDates.length) { - let date = this.vp.selectedDates[0]; - let offset = date.getTimezoneOffset() * 60000; - date.setTime(date.getTime() - offset); - this._model = date; - } else - this.model = null; - this.$.$apply(); - } - - set iniOptions(value) { - this.userOptions = value; - let options = Object.assign({}, this.defaultOptions, value); - this._iniOptions = options; - - // TODO: When some properties change Flatpickr doesn't refresh the view - // for (let option in options) - // this.vp.set(option, options[option]); - - if (this.vp) this.vp.destroy(); - this.vp = new Flatpickr(this.input, this._iniOptions); - this.vp.setDate(this.dateValue); - this.mdlUpdate(); - } - - get iniOptions() { - return this.userOptions; - } - - get model() { - return this._model; - } - - set model(value) { - this._model = value; - this.dateValue = value; - let date; - if (value && this.iniOptions.enableTime) { - date = new Date(value); - let offset = date.getTimezoneOffset() * 60000; - date.setTime(date.getTime() + offset); - } else - date = value; - - this.vp.setDate(date); - this.mdlUpdate(); - } - - onClear() { - this.model = null; - } - - mdlUpdate() { - let mdlField = this.element.firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - } - - $onDestroy() { - this.vp.destroy(); - this.dateValue = undefined; - } -} -DatePicker.$inject = ['$element', '$scope', '$translate', '$attrs']; - -ngModule.component('vnDatePicker', { - template: require('./date-picker.html'), - bindings: { - iniOptions: ' { - let controller; - let $attrs; - let $element; - let today = new Date(); - today.setHours(0, 0, 0, 0); - - beforeEach(angular.mock.module('vnCore', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(angular.mock.inject(($componentController, $translate) => { - $attrs = {}; - $element = angular.element(`
`); - controller = $componentController('vnDatePicker', {$element, $attrs, $translate}); - })); - - describe('onValueUpdate() while date is selected', () => { - it(`should store the selected date in the controller`, () => { - controller.vp = {selectedDates: [today]}; - controller.isLocale = true; - controller.onValueUpdate(); - - expect(controller._model).toEqual(today); - }); - - it(`should format the date`, () => { - controller.vp = {selectedDates: [today], destroy: () => {}}; - controller.isLocale = undefined; - controller._iniOptions.enableTime = undefined; - - controller.onValueUpdate(); - - expect(controller._model).toEqual(today); - }); - }); -}); diff --git a/front/core/components/date-picker/index.js b/front/core/components/date-picker/index.js new file mode 100644 index 000000000..e46cde17e --- /dev/null +++ b/front/core/components/date-picker/index.js @@ -0,0 +1,99 @@ +import ngModule from '../../module'; +import Field from '../field'; +import {Flatpickr} from '../../vendor'; +import './style.scss'; + +class DatePicker extends Field { + constructor($element, $scope, $compile, $translate) { + super($element, $scope, $compile); + this.$translate = $translate; + + this.input = $compile(``)($scope)[0]; + this.initPicker(); + } + + get field() { + return super.field; + } + + set field(value) { + super.field = value; + + let date = value; + if (date && !(date instanceof Date)) + date = new Date(date); + + this.picker.setDate(fixDate(date)); + } + + set options(value) { + let selectedDates = this.picker.selectedDates || []; + this._options = value; + this.initPicker(); + this.picker.setDate(selectedDates[0]); + } + + get options() { + return this._options; + } + + initPicker() { + let locale = this.$translate.use(); + let format = locale == 'es' ? 'd-m-Y' : 'Y-m-d'; + + let options = this.options || {}; + let defaultOptions = { + locale: locale, + dateFormat: format, + enableTime: false, + disableMobile: true, + onValueUpdate: () => this.onValueUpdate() + }; + + if (options.enableTime) { + Object.assign(defaultOptions, { + dateFormat: `${format} h:i`, + time_24hr: true + }); + } + + let mergedOptions = Object.assign({}, + defaultOptions, + options + ); + + if (this.picker) this.picker.destroy(); + this.picker = new Flatpickr(this.input, mergedOptions); + } + + onValueUpdate() { + let date = null; + + if (this.picker.selectedDates.length) + date = this.picker.selectedDates[0]; + + super.field = fixDate(date, -1); + this.$.$applyAsync(); + } + + $onDestroy() { + this.picker.destroy(); + } +} +DatePicker.$inject = ['$element', '$scope', '$compile', '$translate']; + +ngModule.vnComponent('vnDatePicker', { + controller: DatePicker, + bindings: { + options: ' { + let $filter; + let $element; + let $ctrl; + let today; + + beforeEach(angular.mock.module('vnCore', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { + $filter = _$filter_; + + $element = $compile(``)($rootScope); + $ctrl = $element.controller('vnDatePicker'); + + today = new Date(); + today.setUTCHours(0, 0, 0, 0); + })); + + afterEach(() => { + $element.remove(); + }); + + describe('field() setter', () => { + it(`should display the formated the date`, () => { + $ctrl.field = today; + + let displayed = $filter('dateTime')(today, 'yyyy-MM-dd'); + + expect($ctrl.value).toEqual(displayed); + }); + }); + + describe('options() setter', () => { + it(`should display the date with the new format`, () => { + $ctrl.options = {dateFormat: 'Y-m'}; + $ctrl.field = today; + + let displayed = $filter('dateTime')(today, 'yyyy-MM'); + + expect($ctrl.value).toEqual(displayed); + }); + }); +}); diff --git a/front/core/components/date-picker/style.scss b/front/core/components/date-picker/style.scss index d33f27b5d..6af4580f6 100644 --- a/front/core/components/date-picker/style.scss +++ b/front/core/components/date-picker/style.scss @@ -1,24 +1,5 @@ @import "variables"; -vn-date-picker { - .mdl-chip__action { - position: absolute; - width: auto; - top: 0px; - right: -6px; - margin: 22px 0px; - background-color: white; - } - .mdl-textfield { - width: 100%; - } - .material-icons { - font-size: 18px; - float: right; - margin-right: 5px; - } -} - .flatpickr-months .flatpickr-month, .flatpickr-weekdays, span.flatpickr-weekday { diff --git a/front/core/components/dialog/style.scss b/front/core/components/dialog/style.scss index 8fad14e03..406f86148 100644 --- a/front/core/components/dialog/style.scss +++ b/front/core/components/dialog/style.scss @@ -31,7 +31,7 @@ tpl-body { display: block; - width: 20em; + min-width: 20em; } & > button.close { @extend %clickable; diff --git a/front/core/components/drop-down/drop-down.html b/front/core/components/drop-down/drop-down.html index d4dec9dd5..e9a37a675 100755 --- a/front/core/components/drop-down/drop-down.html +++ b/front/core/components/drop-down/drop-down.html @@ -6,10 +6,10 @@
+ placeholder="{{::'Search' | translate}}">
diff --git a/front/core/components/drop-down/drop-down.js b/front/core/components/drop-down/drop-down.js index 8422a60de..e57de0b6d 100755 --- a/front/core/components/drop-down/drop-down.js +++ b/front/core/components/drop-down/drop-down.js @@ -106,8 +106,8 @@ export default class DropDown extends Component { */ show(parent, search) { this._activeOption = -1; - this.search = search; this.$.popover.show(parent || this.parent); + this.search = search; this.buildList(); } @@ -194,10 +194,12 @@ export default class DropDown extends Component { this.document.addEventListener('keydown', this.docKeyDownHandler); this.$.list.scrollTop = 0; this.$.input.focus(); + this.emit('open'); } onClose() { this.document.removeEventListener('keydown', this.docKeyDownHandler); + this.emit('close'); } onClearClick() { diff --git a/front/core/components/drop-down/style.scss b/front/core/components/drop-down/style.scss index a33186a6e..ce26c8508 100755 --- a/front/core/components/drop-down/style.scss +++ b/front/core/components/drop-down/style.scss @@ -13,18 +13,7 @@ display: block; width: 100%; box-sizing: border-box; - border: none; - font-size: inherit; - padding: .6em; - margin: 0!important; - &.not-empty label{ - display: none; - } - & .selected label { - font-size: inherit; - bottom: 2px; - color: $color-font-secondary; - } + padding: $spacing-sm; } & > vn-icon[icon=clear] { display: none; diff --git a/front/core/components/field/index.html b/front/core/components/field/index.html index a2401ee4f..c2e7a02c2 100644 --- a/front/core/components/field/index.html +++ b/front/core/components/field/index.html @@ -5,20 +5,18 @@
-
- -
+
-
+
+ ng-click="$ctrl.onClear($event)">
+
+
diff --git a/front/core/components/field/index.js b/front/core/components/field/index.js index 5d78f0d66..bc60af0d3 100644 --- a/front/core/components/field/index.js +++ b/front/core/components/field/index.js @@ -1,37 +1,63 @@ import ngModule from '../../module'; -import Component from '../../lib/component'; +import FormInput from '../form-input'; import './style.scss'; -export default class Field extends Component { - constructor($element, $scope) { +export default class Field extends FormInput { + constructor($element, $scope, $compile) { super($element, $scope); - this._value = undefined; + this.$compile = $compile; + this.prefix = null; this.suffix = null; - this.input = this.element.querySelector('input'); + this.control = this.element.querySelector('.control'); this.classList = this.element.classList; this.classList.add('vn-field'); + this.element.addEventListener('click', e => this.onClick(e)); - this.element.addEventListener('focusin', - () => this.onFocus(true)); - this.element.addEventListener('focusout', - () => this.onFocus(false)); - this.element.addEventListener('click', - () => this.onClick()); + this.container = this.element.querySelector('.container'); + this.container.addEventListener('mousedown', e => this.onMouseDown(e)); } $onInit() { + super.$onInit(); + if (this.info) this.classList.add('has-icons'); + + this.input.addEventListener('focus', () => this.onFocus(true)); + this.input.addEventListener('blur', () => this.onFocus(false)); + this.input.addEventListener('change', e => { + this.emit('change', {event: e}); + }); } set field(value) { - this._field = value; + if (value === this.field) return; + super.field = value; this.classList.toggle('not-empty', value != null && value !== ''); + this.validateValue(); } get field() { - return this._field; + return super.field; + } + + set input(value) { + if (this.input) this.control.removeChild(this.input); + this._input = value; + this.control.appendChild(value); + } + + get input() { + return this._input; + } + + set value(value) { + this.field = value; + } + + get value() { + return this.input.value; } set type(value) { @@ -42,6 +68,30 @@ export default class Field extends Component { return this.input.type; } + set name(value) { + this.input.name = value; + } + + get name() { + return this.input.name; + } + + set placeholder(value) { + this.input.placeholder = value; + } + + get placeholder() { + return this.input.placeholder; + } + + set tabIndex(value) { + this.input.tabIndex = value; + } + + get tabIndex() { + return this.input.tabIndex; + } + set disabled(value) { this._disabled = boolTag(value); this.input.disabled = this._disabled; @@ -100,20 +150,28 @@ export default class Field extends Component { } set error(value) { + if (value === this.error) return; this._error = value; this.refreshHint(); - this.classList.toggle('invalid', Boolean(value)); } get error() { return this._error; } + get shownError() { + return this.error || this.inputError || null; + } + refreshHint() { - let hint = this.error || this.hint || ''; + let error = this.shownError; + let hint = error || this.hint; + let hintEl = this.element.querySelector('.hint'); - hintEl.innerText = hint; + hintEl.innerText = hint || ''; hintEl.classList.toggle('filled', Boolean(hint)); + + this.classList.toggle('invalid', Boolean(error)); } refreshFix(selector, text) { @@ -123,16 +181,27 @@ export default class Field extends Component { } onClick() { + if (event.defaultPrevented) return; + event.preventDefault(); + if (this.input !== document.activeElement) - this.input.focus(); + this.focus(); + } + + onMouseDown(event) { + if (event.target == this.input) return; + event.preventDefault(); + this.focus(); } onFocus(hasFocus) { this.classList.toggle('focused', hasFocus); } - onClear() { - this.input.value = ''; + onClear(event) { + if (event.defaultPrevented) return; + event.preventDefault(); + this.field = null; this.input.dispatchEvent(new Event('change')); } @@ -143,10 +212,28 @@ export default class Field extends Component { select() { this.input.select(); } -} -Field.$inject = ['$element', '$scope']; -ngModule.component('vnField', { + buildInput(type) { + let template = ``; + this.input = this.$compile(template)(this.$)[0]; + } + + /** + * If input value is invalid, sets the error message as hint. + */ + validateValue() { + let error = this.input.checkValidity() + ? null + : this.input.validationMessage; + + if (error === this.inputError) return; + this.inputError = error; + this.refreshHint(); + } +} +Field.$inject = ['$element', '$scope', '$compile']; + +ngModule.vnComponent('vnField', { template: require('./index.html'), transclude: { prepend: '?prepend', @@ -154,18 +241,17 @@ ngModule.component('vnField', { }, controller: Field, bindings: { - field: '=?', - label: '@?', - name: '@?', type: '@?', + placeholder: '@?', + value: '=?', info: '@?', - disabled: '@?', - readonly: '@?', - required: '@?', + required: ' .infix { position: relative; @@ -50,36 +49,40 @@ & > .control { height: 100%; flex: auto; - } - & > .control > input { - padding-top: 24px; - padding-bottom: 8px; - height: inherit; - outline: none; - border: none; - font-family: Arial, sans-serif; - display: block; - font-size: $input-font-size; - width: 100%; - background: 0; - color: inherit; - box-sizing: border-box; - &[type=time], - &[type=date] { - clip-path: inset(0 20px 0 0); - } - &[type=number] { - -moz-appearance: textfield; - - &::-webkit-outer-spin-button, - &::-webkit-inner-spin-button { - -webkit-appearance: none; - margin: 0; + & > * { + padding-top: 24px; + padding-bottom: 8px; + height: inherit; + outline: none; + border: none; + font-family: Arial, sans-serif; + display: block; + font-size: $input-font-size; + width: 100%; + background: 0; + color: inherit; + box-sizing: border-box; + min-height: 56px; + + &[type=time], + &[type=date] { + clip-path: inset(0 20px 0 0); + opacity: 0; + transition: opacity 200ms ease-in-out; + } + &[type=number] { + -moz-appearance: textfield; + + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + } + &:invalid { + box-shadow: none; } - } - &:invalid { - box-shadow: none; } } } @@ -102,12 +105,16 @@ & > .prepend > prepend { padding-right: 12px; } - & > .append > append { - padding-left: 12px; - } - & > .icons > vn-icon[icon=clear] { - display: none; - cursor: pointer; + & > .icons { + &.pre { + padding-left: 12px; + } + & > vn-icon { + cursor: pointer; + } + & > vn-icon[icon=clear] { + display: none; + } } & > .underline { position: absolute; @@ -131,28 +138,56 @@ } } } - &.not-empty > .container, - &.focused > .container { - & > .infix { - & > .fix { - opacity: 1; + &.dense { + & > .hint { + display: none; + } + & > .container > .infix { + & > label { + top: 8px; } + & > .control > * { + padding-top: 8px; + min-height: 40px; + } + } + &.not-empty, + &.focused, + &.invalid { + & > .container > .infix > label { + top: 0; + line-height: 8px; + } + } + } + &.not-empty, + &.focused, + &.invalid { + & > .container > .infix { & > label { top: 5px; color: $color-main; padding: 0; font-size: 12px; } + & > .control > * { + &[type=time], + &[type=date] { + opacity: 1; + } + } } } &.has-icons, &.not-empty:hover, &.not-empty.focused { - & > .container > .append > append { - padding-left: 0; - } - & > .container > .icons { - padding-left: 12px; + & > .container { + & > .append > append { + padding-left: 0; + } + & > .icons.pre { + padding-left: 12px; + } } } &:not(.disabled):not(.readonly) { @@ -170,14 +205,8 @@ } } } - &:not(.not-empty):not(.focused) > .container > .infix > .control > input { - &[type=time], - &[type=date] { - opacity: 0; - } - } &.readonly > .container { - & > .infix > .control > input { + & > .infix > .control > * { caret-color: transparent; } & > .underline.blur { @@ -186,11 +215,11 @@ } & > .hint { z-index: -1; - padding-top: 8px; - height: 20px; + padding: 4px 0; + height: 12px; color: rgba(0, 0, 0, .4); font-size: 12px; - transform: translateY(-28px); + transform: translateY(-12px); transition-property: opacity, transform, color; transition-duration: 200ms; transition-timing-function: ease-in-out; @@ -220,8 +249,3 @@ } } } -vn-table { - .vn-field { - margin: 0; - } -} diff --git a/front/core/components/form-input/index.js b/front/core/components/form-input/index.js new file mode 100644 index 000000000..74d98079c --- /dev/null +++ b/front/core/components/form-input/index.js @@ -0,0 +1,58 @@ +import ngModule from '../../module'; +import Component from '../../lib/component'; + +/** + * Base component for form inputs. + * + * @property {String} label Label to display along the component + * @property {any} field The value with which the element is linked + * @property {Boolean} disabled Put component in disabled mode + */ +export default class FormInput extends Component { + $onInit() { + // XXX: Compatibility with old inputs + let attrs = this.$element[0].attributes; + if (!this.name && attrs['ng-model']) { + let split = attrs['ng-model'].nodeValue.split('.'); + this.name = split[split.length - 1]; + } + + if (!this.ngModel) return; + this.ngModel.$render = () => { + this.field = this.ngModel.$viewValue; + }; + } + + set field(value) { + this._field = value; + + if (this.ngModel) + this.ngModel.$setViewValue(value); + } + + get field() { + return this._field; + } + + set name(value) { + this.element.setAttribute('name', value); + } + + get name() { + return this.element.getAttribute('name'); + } +} + +ngModule.vnComponent('vnFormInput', { + controller: FormInput, + bindings: { + label: '@?', + field: '=?', + name: '@?', + disabled: ' { beforeEach(angular.mock.inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $attrs = {field: '$ctrl.dms.file'}; - $element = angular.element('
'); + $element = angular.element('
'); controller = $componentController('vnInputFile', {$element, $scope, $attrs, $timeout, $transclude: () => {}}); controller.input = $element[0].querySelector('input'); controller.validate = () => {}; diff --git a/front/core/components/input-file/style.scss b/front/core/components/input-file/style.scss index 83a66a262..c5dd8922b 100644 --- a/front/core/components/input-file/style.scss +++ b/front/core/components/input-file/style.scss @@ -1,8 +1,6 @@ @import "variables"; -@import '../textfield/style.scss'; vn-input-file { - @extend vn-textfield; .value { color: $color-font-secondary; cursor: pointer; @@ -12,4 +10,156 @@ vn-input-file { input { display: none !important } + margin: 20px 0; + display: inline-block; + width: 100%; + + & > .container { + width: 100%; + position: relative; + padding-bottom: 2px; + display: flex; + + & > .textField { + width: 100%; + display: flex; + align-items: center; + position: relative; + padding-top: 4px; + } + } + + .leftIcons, .rightIcons, .suffix { + display: flex; + color: $color-font-secondary; + + .material-icons { + font-size: 20px !important + } + } + + .suffix vn-icon-button { + padding: 0 + } + + t-left-icons { + padding-right: 0.5em + } + + t-right-icons { + padding-left: 0.5em + } + + .infix { + position: relative; + display: block; + flex: auto; + width: 100%; + min-width: 0; + } + i.clear { + visibility: hidden; + cursor: pointer; + outline: 0; + + &:hover { + color: #222; + } + } + &:hover i.clear { + visibility: visible; + } + i.visible { + visibility: visible; + } + label { + position: absolute; + bottom: 0; + left: 0; + padding: 4px 0!important; + pointer-events: none; + color: $color-font-secondary; + transition-duration: .2s; + transition-timing-function: cubic-bezier(.4,0,.2,1); + } + &.not-empty label{ + bottom: 24px; + color: $color-main; + padding: 0; + font-size: 12px; + } + input { + outline: none; + border: none; + font-family: "Helvetica", "Arial", sans-serif; + display: block; + font-size: 16px; + width: 100%; + background: 0 0; + color: inherit; + padding: 4px; + box-sizing: border-box; + border-bottom: 0!important; + + &[type=number] { + -moz-appearance: textfield; + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + } + &:invalid { + box-shadow: none; + } + } + .underline { + position: absolute; + bottom: 0; + height: 1px; + content: ' '; + pointer-events: none; + width: 100%; + background-color: $color-input-underline; + } + .selected.underline { + background-color: $color-main; + height: 2px; + left: 50%; + width: 0px !important; + transition-duration: 0.2s; + transition-timing-function: cubic-bezier(.4,0,.2,1); + } + + div.selected { + &.container{ + border-bottom: 0px; + } + label { + bottom: 24px; + color: $color-main; + font-size: 12px; + } + .selected.underline{ + left: 0; + width: 100%!important; + } + } + & > div.container > div.textField > div.infix.invalid { + @extend div.selected; + + & > span.mdl-textfield__error { + visibility: visible; + } + & > label { + color: #d50000; + } + } + .infix.invalid + .underline { + background-color: #d50000; + } + + label span:nth-child(2) { + color: $color-alert + } } \ No newline at end of file diff --git a/front/core/components/input-number/index.html b/front/core/components/input-number/index.html index 19b5c58e6..ee6f50397 100644 --- a/front/core/components/input-number/index.html +++ b/front/core/components/input-number/index.html @@ -1,48 +1,48 @@ -
-
-
-
-
- - -
-
-
-
- - - - - - info_outline - -
-
+
+
+
+
+
+
+ +
+
+ + + + +
+
+
+
+ + + + +
+
+
+
\ No newline at end of file diff --git a/front/core/components/input-number/index.js b/front/core/components/input-number/index.js index dfb9ee3aa..3ace0a016 100644 --- a/front/core/components/input-number/index.js +++ b/front/core/components/input-number/index.js @@ -1,48 +1,10 @@ import ngModule from '../../module'; -import Input from '../../lib/input'; -import './style.scss'; +import Field from '../field'; -export default class InputNumber extends Input { - constructor($element, $scope, $attrs, vnTemplate) { - super($element, $scope); - this.displayControls = false; - this.hasFocus = false; - - vnTemplate.normalizeInputAttrs($attrs); - this.registerEvents(); - } - - /** - * Registers all event emitters - */ - registerEvents() { - this.input.addEventListener('change', event => { - this.validateValue(); - this.emit('change', {event}); - }); - } - - /** - * Gets current value - */ - get value() { - return this._value; - } - - /** - * Sets input value - * - * @param {Number} value - Value - */ - set value(value) { - this.hasValue = !(value === null || value === undefined || value === ''); - - if (!this.hasOwnProperty('_value') && this.hasValue || value === '') - this.input.value = value; - - this._value = value; - this.element.classList.toggle('not-empty', this.hasValue); - this.validateValue(); +export default class InputNumber extends Field { + constructor($element, $scope, $compile) { + super($element, $scope, $compile); + this.buildInput('number'); } /** @@ -58,7 +20,8 @@ export default class InputNumber extends Input { * @param {Number} value - Value */ set max(value) { - if (value) this.input.max = value; + this.input.max = value; + this.validateValue(); } /** @@ -74,7 +37,8 @@ export default class InputNumber extends Input { * @param {Number} value - Value */ set min(value) { - if (value) this.input.min = value; + this.input.min = value; + this.validateValue(); } /** @@ -90,47 +54,38 @@ export default class InputNumber extends Input { * @param {Number} value - Value */ set step(value) { - if (value) this.input.step = value; + this.input.step = value; + this.validateValue(); } - /** - * Increases the input value - */ stepUp() { this.input.stepUp(); - this.input.dispatchEvent(new Event('change')); } - /** - * Decreases the input value - */ stepDown() { this.input.stepDown(); + } + + onStep(event, way) { + if (event.defaultPrevented) return; + event.preventDefault(); + + if (way == 'up') + this.stepUp(); + else + this.stepDown(); + this.input.dispatchEvent(new Event('change')); } } -InputNumber.$inject = ['$element', '$scope', '$attrs', 'vnTemplate']; -ngModule.component('vnInputNumber', { +ngModule.vnComponent('vnInputNumber', { template: require('./index.html'), controller: InputNumber, - transclude: { - leftIcons: '?tLeftIcons', - rightIcons: '?tRightIcons' - }, bindings: { - label: '@?', - name: '@?', - disabled: ' { - let $scope; - let $attrs; - let $timeout; let $element; - let controller; + let $ctrl; beforeEach(angular.mock.module('vnCore', $translateProvider => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $attrs = {field: '$ctrl.client.socialName'}; - $element = angular.element('
'); - controller = $componentController('vnInputNumber', {$element, $scope, $attrs, $timeout, $transclude: () => {}}); - controller.input = $element[0].querySelector('input'); - controller.validate = () => {}; + beforeEach(angular.mock.inject(($compile, $rootScope) => { + $element = $compile(``)($rootScope); + $ctrl = $element.controller('vnInputNumber'); })); - describe('value() setter', () => { - it(`should set a value, add the class 'not-empty' and then call validateValue() method`, () => { - spyOn(controller, 'validateValue'); + afterEach(() => { + $element.remove(); + }); - controller.value = 10; + describe('min() setter', () => { + it(`should set error property when value is lower than min`, () => { + $ctrl.field = -1; + $ctrl.min = 0; - let classes = controller.element.classList.toString(); - - expect(classes).toContain('not-empty'); - expect(controller.validateValue).toHaveBeenCalledWith(); + // FIXME: Input validation doesn't work with Jest? + // expect($ctrl.shownError).toContain('Please select a value that is no less than 0'); + expect($ctrl.shownError).toBeNull(); }); - it(`should set an empty value, remove the class 'not-empty' and then call validateValue() method`, () => { - spyOn(controller, 'validateValue'); + it(`should unset error property when value is upper than min`, () => { + $ctrl.field = 1; + $ctrl.min = 0; - controller.value = null; - - let classes = controller.element.classList.toString(); - - expect(classes).not.toContain('not-empty'); - expect(controller.validateValue).toHaveBeenCalledWith(); + expect($ctrl.shownError).toBeNull(); }); }); - describe('validateValue()', () => { - it(`should call hasValidValue() and not add the class invalid and validated`, () => { - controller.input.min = 0; - controller.input.value = 10; + describe('max() setter', () => { + it(`should set error property when value is upper than max`, () => { + $ctrl.field = 1; + $ctrl.max = 0; - controller.validateValue(); - let classes = controller.element.querySelector('.infix').classList.toString(); - - expect(classes).not.toContain('validated invalid'); + // FIXME: Input validation doesn't work with Jest? + // expect($ctrl.shownError).toContain('Please select a value that is no more than 0'); + expect($ctrl.shownError).toBeNull(); }); - it(`should call hasValidValue() and add the class invalid and validated`, () => { - controller.input.min = 0; - controller.input.value = -10; + // FIXME: Input validation doesn't work with Jest? + it(`should unset error property when value is lower than max`, () => { + $ctrl.field = -1; + $ctrl.min = 0; - controller.validateValue(); - let classes = controller.element.querySelector('.infix').classList.toString(); + expect($ctrl.shownError).toBeNull(); + }); + }); - expect(classes).toContain('validated invalid'); + describe('step() setter', () => { + it(`should increase value when add icon is clicked`, () => { + $ctrl.step = 1; + $ctrl.field = 1; + + // FIXME: Doesn't work with Jest? + // $ctrl.stepUp(); + // $element[0].querySelector('vn-icon[icon=add]').click(); + + expect($ctrl.field).toBe(1); }); }); }); diff --git a/front/core/components/input-number/style.scss b/front/core/components/input-number/style.scss deleted file mode 100644 index e25299db2..000000000 --- a/front/core/components/input-number/style.scss +++ /dev/null @@ -1,16 +0,0 @@ -@import "variables"; -@import '../textfield/style.scss'; - -vn-input-number { - @extend vn-textfield; - - vn-icon[icon=add], - vn-icon[icon=remove] { - &:not(:hover){ - color: $color-font-secondary; - } - i { - user-select: none; - } - } -} \ No newline at end of file diff --git a/front/core/components/input-time/index.html b/front/core/components/input-time/index.html deleted file mode 100644 index cc84b17c2..000000000 --- a/front/core/components/input-time/index.html +++ /dev/null @@ -1,26 +0,0 @@ -
-
-
-
- - -
-
-
-
- - info_outline - -
-
-
-
diff --git a/front/core/components/input-time/index.js b/front/core/components/input-time/index.js index c85bb37cf..9c6ae0e4a 100644 --- a/front/core/components/input-time/index.js +++ b/front/core/components/input-time/index.js @@ -1,80 +1,41 @@ import ngModule from '../../module'; -import Input from '../../lib/input'; -import './style.scss'; +import Field from '../field'; -export default class InputTime extends Input { - constructor($element, $scope, $filter) { - super($element, $scope); +export default class InputTime extends Field { + constructor($element, $scope, $compile, $filter) { + super($element, $scope, $compile); this.$filter = $filter; - this.registerEvents(); + this.input = $compile(``)($scope)[0]; + this.input.addEventListener('change', () => this.onValueUpdate()); } - registerEvents() { - this.input.addEventListener('change', event => { - this.onTimeChange(); - this.emit('change', {event}); - }); - - this.input.addEventListener('focus', event => { - this.emit('focus', {event}); - }); + get field() { + return super.field; } - /** - * Gets current value - */ - get value() { - return this._value; - } - - /** - * Sets input value - * - * @param {Number} value - Value - */ - set value(value) { - this.updateValue(value); + set field(value) { this.input.value = this.$filter('dateTime')(value, 'HH:mm'); + super.field = value; } - updateValue(value) { - this._value = value; - this.element.classList.toggle('not-empty', value != null); - this.validateValue(); - } - - onTimeChange() { + onValueUpdate() { let date = null; let value = this.input.value; if (value) { let split = value.split(':').map(i => parseInt(i) || null); - date = new Date(this.value || null); + date = new Date(this.field || null); date.setHours(split[0], split[1], 0, 0); } - this.updateValue(date); + super.field = date; + this.$.$applyAsync(); } } -InputTime.$inject = ['$element', '$scope', '$filter']; +InputTime.$inject = ['$element', '$scope', '$compile', '$filter']; -ngModule.component('vnInputTime', { - template: require('./index.html'), - controller: InputTime, - transclude: { - leftIcons: '?tLeftIcons', - rightIcons: '?tRightIcons' - }, - bindings: { - label: '@?', - disabled: ' { - let $scope; - let $attrs; - let $timeout; + let $filter; let $element; - let controller; + let $ctrl; beforeEach(angular.mock.module('vnCore', $translateProvider => { $translateProvider.translations('en', {}); })); - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $attrs = {field: '$ctrl.zone.hour'}; - $element = angular.element('
'); - controller = $componentController('vnInputTime', {$element, $scope, $attrs, $timeout, $transclude: () => {}}); + beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { + $filter = _$filter_; + + $element = $compile(``)($rootScope); + $ctrl = $element.controller('vnInputTime'); })); - describe('value() setter', () => { - it(`should set _value to a given value, add the class not-empty and remove invalid and validated`, () => { - const today = new Date(); - controller.value = today; - let classes = controller.element.classList.toString(); + afterEach(() => { + $element.remove(); + }); - expect(classes).toContain('not-empty'); - expect(controller._value).toEqual(today); + describe('field() setter', () => { + it(`should display the formated the date`, () => { + let date = new Date(); + $ctrl.field = date; + let displayed = $filter('dateTime')(date, 'HH:mm'); - classes = controller.element.querySelector('.infix').classList.toString(); - - expect(classes).not.toContain('invalid validated'); - }); - - it(`should set _value to a given value and not add the class not-empty if the given value is null`, () => { - controller.value = null; - let classes = controller.element.classList.toString(); - - expect(classes).not.toContain('not-empty'); - expect(controller._value).toEqual(null); + expect($ctrl.value).toEqual(displayed); }); }); }); diff --git a/front/core/components/input-time/style.scss b/front/core/components/input-time/style.scss deleted file mode 100644 index dfd6be541..000000000 --- a/front/core/components/input-time/style.scss +++ /dev/null @@ -1,12 +0,0 @@ -@import "variables"; -@import '../textfield/style.scss'; - -vn-input-time { - @extend vn-textfield; - - input[type="time"] { - clip-path: inset(0 17px 0 0); - outline: none; - outline: 0; - } -} \ No newline at end of file diff --git a/front/core/components/multi-check/multi-check.html b/front/core/components/multi-check/multi-check.html index c09fd246c..86c35d6d0 100644 --- a/front/core/components/multi-check/multi-check.html +++ b/front/core/components/multi-check/multi-check.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/front/core/components/popover/popover.js b/front/core/components/popover/popover.js index be6546246..af6edb79a 100644 --- a/front/core/components/popover/popover.js +++ b/front/core/components/popover/popover.js @@ -109,7 +109,6 @@ export default class Popover extends Component { this.showTimeout = null; this.element.style.display = 'none'; this.document.body.removeChild(this.element); - this.emit('close'); }, 250); this.document.removeEventListener('keydown', this.docKeyDownHandler); @@ -118,8 +117,8 @@ export default class Popover extends Component { this.element.removeEventListener('mousedown', this.bgMouseDownHandler); this.bgMouseDownHandler = null; - if (this.deregisterCallback) - this.deregisterCallback(); + if (this.deregisterCallback) this.deregisterCallback(); + this.emit('close'); } /** @@ -189,8 +188,9 @@ export default class Popover extends Component { } onBgMouseDown(event) { - if (event != this.lastMouseEvent) - this.hide(); + if (event == this.lastMouseEvent || event.defaultPrevented) return; + event.preventDefault(); + this.hide(); } } Popover.$inject = ['$element', '$scope', '$timeout', '$transitions', '$transclude', '$compile']; diff --git a/front/core/components/radio/index.js b/front/core/components/radio/index.js index e965196c8..019668330 100644 --- a/front/core/components/radio/index.js +++ b/front/core/components/radio/index.js @@ -10,13 +10,13 @@ import './style.scss'; */ export default class Radio extends Toggle { set field(value) { - this._field = value; + super.field = value; this.element.classList.toggle('checked', Boolean(value) && value == this.val); } get field() { - return this._field; + return super.field; } set checked(value) { @@ -43,14 +43,10 @@ export default class Radio extends Toggle { } } -ngModule.component('vnRadio', { +ngModule.vnComponent('vnRadio', { template: require('../toggle/index.html'), controller: Radio, bindings: { - label: '@?', - field: '=?', - disabled: ' - - - - - - - - + + + + + + - - - - - - + + + + + form > vn-horizontal > vn-icon-button { - color: black; - } } .search-panel { diff --git a/front/core/components/table/index.html b/front/core/components/table/index.html index e7ae44886..5c36dd6a0 100644 --- a/front/core/components/table/index.html +++ b/front/core/components/table/index.html @@ -1,2 +1,2 @@ -
+
\ No newline at end of file diff --git a/front/core/components/table/style.scss b/front/core/components/table/style.scss index 9c14e3e03..839e1a7bb 100644 --- a/front/core/components/table/style.scss +++ b/front/core/components/table/style.scss @@ -5,181 +5,169 @@ vn-table { display: block; overflow: auto; width: 100%; +} +.vn-table { + width: 100%; + display: table; + border-collapse: collapse; - & > div { - width: inherit; - display: table; - border-collapse: collapse; + & > vn-thead, + & > thead { + display: table-header-group; + border-bottom: .15em solid $color-spacer; - & > vn-thead { - display: table-header-group; - border-bottom: .15em solid $color-spacer; + & > * > th { + font-weight: normal; + } + & > * > vn-th[field] { + position: relative; + overflow: visible; + cursor: pointer; - & > * > vn-th[field] { - position: relative; - overflow: visible; - cursor: pointer; - - &.active > :after { - color: $color-font; - opacity: 1; - } - &.desc > :after { - content: 'arrow_drop_down'; - } - &.asc > :after { - content: 'arrow_drop_up'; - } - & > :after { - font-family: 'Material Icons'; - content: 'arrow_drop_down'; - position: absolute; - color: $color-spacer; - opacity: 0; - } - &:hover > :after { - opacity: 1; - } + &.active > :after { + color: $color-font; + opacity: 1; + } + &.desc > :after { + content: 'arrow_drop_down'; + } + &.asc > :after { + content: 'arrow_drop_up'; + } + & > :after { + font-family: 'Material Icons'; + content: 'arrow_drop_down'; + position: absolute; + color: $color-spacer; + opacity: 0; + } + &:hover > :after { + opacity: 1; } } - & > vn-tbody { - display: table-row-group; - } - & > vn-tfoot { - border-top: .15em solid $color-spacer; - display: table-footer-group - } - & > * > vn-tr, - & > * > a.vn-tr { + } + & > vn-tbody, + & > tbody { + display: table-row-group; + } + & > vn-tfoot, + & > tfoot { + border-top: .15em solid $color-spacer; + display: table-footer-group + } + & > * > vn-tr, + & > * > a.vn-tr, + & > * > tr { + display: table-row; + height: 3em; + } + vn-thead, vn-tbody, vn-tfoot, + thead, tbody, tfoot { + & > * { display: table-row; - height: 3em; - } - vn-thead, vn-tbody, vn-tfoot { - & > * { - display: table-row; - & > vn-th { - color: $color-font-light; - padding-top: 1em; - padding-bottom: .8em; + & > vn-th, + & > th { + color: $color-font-light; + padding-top: 1em; + padding-bottom: .8em; + } + & > vn-th, + & > vn-td, + & > th, + & > td { + overflow: hidden; + } + & > vn-th, + & > vn-td, + & > vn-td-editable, + & > th, + & > td { + vertical-align: middle; + display: table-cell; + text-align: left; + padding: .6em .5em; + white-space: nowrap; + text-overflow: ellipsis; + max-width: 5em; + + &[number] { + text-align: right; + width: 6em; } - & > vn-th, - & > vn-td { - overflow: hidden; + &[center] { + text-align: center; } - & > vn-th, - & > vn-td, - & > vn-td-editable { - vertical-align: middle; - display: table-cell; - text-align: left; - padding: .6em .5em; - white-space: nowrap; - text-overflow: ellipsis; - max-width: 5em; - - &[number] { - text-align: right; - width: 6em; - } - &[center] { - text-align: center; - } - &[shrink] { - width: 1px; - text-align: center; - } - &[expand] { - max-width: 10em; - min-width: 0; - } - vn-icon.bright, i.bright { - color: #f7931e; - } + &[shrink] { + width: 1px; + text-align: center; } - & > :last-child { - padding-right: 1.4em; + &[expand] { + max-width: 10em; + min-width: 0; } - & > :first-child { - padding-left: 1.4em; + vn-icon.bright, i.bright { + color: #f7931e; } } - & > a.vn-tr { - color: inherit; + & > :last-child { + padding-right: 1.4em; + } + & > :first-child { + padding-left: 1.4em; } } - vn-tbody > * { - border-bottom: .1em solid $color-spacer-light; + & > a.vn-tr { + color: inherit; + } + } + vn-tbody > *, + tbody > * { + border-bottom: .1em solid $color-spacer-light; - &:last-child { - border-bottom: none; - } - &.clickable { - @extend %clickable; - } - & > vn-td .chip { + &:last-child { + border-bottom: none; + } + &.clickable { + @extend %clickable; + } + & > vn-td, + & > td { + .chip { padding: .3em; - border-radius: .3em - } - - & > vn-td .chip.notice { + border-radius: .3em; color: $color-font-bg; - background-color: $color-notice-medium - } - & > vn-td .chip.success { - color: $color-font-bg; - background-color: $color-success-medium + &.notice { + background-color: $color-notice-medium + } + &.success { + background-color: $color-success-medium; + } + &.warning { + background-color: $color-main-medium; + } + &.alert { + background-color: $color-alert-medium; + } + &.message { + color: $color-font-dark; + background-color: $color-bg-dark + } } - - & > vn-td .chip.warning { - color: $color-font-bg; - background-color: $color-main-medium; - } - - & > vn-td .chip.alert { - color: $color-font-bg; - background-color: $color-alert-medium; - } - - & > vn-td .chip.message { - color: $color-font-dark; - background-color: $color-bg-dark - } - - & > vn-td vn-icon-menu { + vn-icon-menu { display: inline-block; color: $color-main; padding: .25em } + } + & > [actions] { + width: 1px; - & > [actions] { - width: 1px; - - & > * { - vertical-align: middle; - } + & > * { + vertical-align: middle; } } - & > vn-empty-rows { - display: table-caption; - caption-side: bottom; - text-align: center; - padding: 1.5em; - width: 100%; - box-sizing: border-box; - } - } - vn-autocomplete { - div.mdl-textfield { - padding: 0 !important; - } - label.mdl-textfield__label:after { - bottom: 0; - } - div.icons { - display: none !important; - } } vn-textfield { float: right; diff --git a/front/core/components/textarea/index.js b/front/core/components/textarea/index.js new file mode 100644 index 000000000..fc0834566 --- /dev/null +++ b/front/core/components/textarea/index.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; +import Field from '../field'; + +export default class Textarea extends Field { + constructor($element, $scope, $compile) { + super($element, $scope, $compile); + + let html = ``; + this.input = $compile(html)($scope)[0]; + } + + set rows(value) { + this.input.rows = typeof value == 'number' && value > 0 ? value : 3; + } + + get rows() { + return this.input.rows; + } +} + +ngModule.vnComponent('vnTextarea', { + controller: Textarea, + bindings: { + rows: ' { + let $element; + let $ctrl; + + beforeEach(angular.mock.module('vnCore', $translateProvider => { + $translateProvider.translations('en', {}); + })); + + beforeEach(angular.mock.inject(($compile, $rootScope) => { + $element = $compile(``)($rootScope); + $ctrl = $element.controller('vnTextarea'); + })); + + afterEach(() => { + $element.remove(); + }); + + describe('rows() setter', () => { + it(`should set rows property of the element to the given value if it's a valid number`, () => { + $ctrl.rows = 27; + + expect($ctrl.rows).toEqual(27); + }); + + it(`should set rows property of the element to 3 if the given value if it's null`, () => { + $ctrl.rows = null; + + expect($ctrl.rows).toEqual(3); + }); + + it(`should set rows property of the element to 3 if the given value if it's not a valid number`, () => { + $ctrl.rows = 'a'; + + expect($ctrl.rows).toEqual(3); + }); + }); +}); diff --git a/front/core/components/textarea/style.scss b/front/core/components/textarea/style.scss deleted file mode 100644 index 2f6b521b3..000000000 --- a/front/core/components/textarea/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "variables"; - -vn-textarea { - & > .mdl-textfield { - width: initial; - display: block; - } - label { - position: absolute; - bottom: 0; - pointer-events: none; - color: $color-font-secondary; - transition-duration: .2s; - transition-timing-function: cubic-bezier(.4,0,.2,1); - } - & textarea.ng-not-empty+label.placeholder{ - top: 5px; - color: $color-main; - padding: 0; - font-size: 12px; - visibility: visible!important; - content: normal!important; - } -} \ No newline at end of file diff --git a/front/core/components/textarea/textarea.html b/front/core/components/textarea/textarea.html deleted file mode 100644 index 6efe39f7a..000000000 --- a/front/core/components/textarea/textarea.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - -
diff --git a/front/core/components/textarea/textarea.js b/front/core/components/textarea/textarea.js deleted file mode 100644 index 9b30546c3..000000000 --- a/front/core/components/textarea/textarea.js +++ /dev/null @@ -1,43 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; - -export default class Textarea { - constructor($element, $scope, $attrs, vnTemplate) { - this.$ = $scope; - this.$attrs = $attrs; - this.element = $element; - vnTemplate.normalizeInputAttrs($attrs); - this.textarea = this.element[0].querySelector('textarea'); - this.rows = null; - } - set model(value) { - this._model = value; - this.mdlUpdate(); - } - set rows(value) { - this.textarea.rows = value ? value : 3; - } - get model() { - return this._model; - } - mdlUpdate() { - let mdlField = this.element[0].firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); - componentHandler.upgradeElement(this.element[0].firstChild); - } -} -Textarea.$inject = ['$element', '$scope', '$attrs', 'vnTemplate']; - -ngModule.component('vnTextarea', { - template: require('./textarea.html'), - controller: Textarea, - bindings: { - model: '=model', - label: '@?', - rows: '@?', - name: '@?', - disabled: ' { - let $scope; - let $attrs; - let $element; - let controller; - - beforeEach(angular.mock.module('vnCore', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $attrs = {field: '$ctrl.claim.observation'}; - $element = angular.element('