diff --git a/back/methods/user-config/getUserConfig.js b/back/methods/user-config/getUserConfig.js index 192d973c2..663ef71b4 100644 --- a/back/methods/user-config/getUserConfig.js +++ b/back/methods/user-config/getUserConfig.js @@ -13,18 +13,26 @@ module.exports = function(Self) { }); Self.getUserConfig = async ctx => { - let userConfig = await Self.app.models.UserConfig.findOne({ + const models = Self.app.models; + + let userConfig = await models.UserConfig.findOne({ where: {userFk: ctx.req.accessToken.userId} }); + const companyFilter = {where: {code: 'VNL'}}; + const company = await models.Company.findOne(companyFilter); + + const warehouseFilter = {where: {code: 'ALG'}}; + const warehouse = await models.Warehouse.findOne(warehouseFilter); + if (!userConfig) { let newConfig = { - warehouseFk: 1, - companyFk: 442, + warehouseFk: warehouse.id, + companyFk: company.id, userFk: ctx.req.accessToken.userId }; - userConfig = await Self.app.models.UserConfig.create(newConfig); + userConfig = await models.UserConfig.create(newConfig); } return userConfig; }; diff --git a/back/methods/user-config/specs/getUserConfig.spec.js b/back/methods/user-config/specs/getUserConfig.spec.js index da3fc958f..c86f3e0f2 100644 --- a/back/methods/user-config/specs/getUserConfig.spec.js +++ b/back/methods/user-config/specs/getUserConfig.spec.js @@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server'); describe('userConfig getUserConfig()', () => { it(`should return the configuration data of a given user`, async() => { - await app.models.UserConfig.getUserConfig({req: {accessToken: {userId: 9}}}) - .then(response => { - expect(response.warehouseFk).toEqual(1); - }); + const result = await app.models.UserConfig.getUserConfig({req: {accessToken: {userId: 9}}}); + + expect(result.warehouseFk).toEqual(1); + expect(result.companyFk).toEqual(442); }); }); diff --git a/back/models/warehouse.json b/back/models/warehouse.json index fc6baacbc..1d8ca44e3 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -16,6 +16,9 @@ "name": { "type": "String" }, + "code": { + "type": "String" + }, "isInventory": { "type": "Number" }, diff --git a/db/changes/10300-newFacility/00-saleValue.sql b/db/changes/10300-newFacility/00-saleValue.sql deleted file mode 100644 index 5165bd4a5..000000000 --- a/db/changes/10300-newFacility/00-saleValue.sql +++ /dev/null @@ -1,26 +0,0 @@ -CREATE OR REPLACE DEFINER = root@`%` VIEW `vn`.`saleValue` AS -SELECT `wh`.`name` AS `warehouse`, - `c`.`name` AS `client`, - `c`.`typeFk` AS `clientTypeFk`, - `u`.`name` AS `buyer`, - `it`.`id` AS `itemTypeFk`, - `it`.`name` AS `family`, - `s`.`itemFk` AS `itemFk`, - `s`.`concept` AS `concept`, - `s`.`quantity` AS `quantity`, - `b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue` AS `cost`, - (`b`.`buyingValue` + `b`.`freightValue` + `b`.`comissionValue` + `b`.`packageValue`) * `s`.`quantity` AS `value`, - `tm`.`year` AS `year`, - `tm`.`week` AS `week` -FROM `vn`.`sale` `s` - JOIN `vn`.`item` `i` ON `i`.`id` = `s`.`itemFk` - JOIN `vn`.`itemType` `it` ON `it`.`id` = `i`.`typeFk` - JOIN `account`.`user` `u` ON `u`.`id` = `it`.`workerFk` - JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk` - JOIN `vn`.`client` `c` ON `c`.`id` = `t`.`clientFk` - JOIN `vn`.`warehouse` `wh` ON `wh`.`id` = `t`.`warehouseFk` - JOIN `vn`.`time` `tm` ON `tm`.`dated` = CAST(`t`.`shipped` AS DATE) - JOIN `cache`.`last_buy` `lb` ON `lb`.`item_id` = `i`.`id` AND `lb`.`warehouse_id` = `wh`.`id` - JOIN `vn`.`buy` `b` ON `b`.`id` = `lb`.`buy_id` -WHERE `wh`.`isManaged` <> 0; - diff --git a/db/changes/10300-newFacility/00-supplierBeneficiary.sql b/db/changes/10300-newFacility/00-supplierBeneficiary.sql deleted file mode 100644 index fcd5a1e2e..000000000 --- a/db/changes/10300-newFacility/00-supplierBeneficiary.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.`supplierAccount` ADD `beneficiary` VARCHAR(50) NULL DEFAULT NULL AFTER `bankFk`; -UPDATE vn.supplierAccount SET beneficiary = `description`; diff --git a/db/changes/10300-newFacility/00-weekWaste.sql b/db/changes/10300-newFacility/00-weekWaste.sql deleted file mode 100644 index 4883a49fc..000000000 --- a/db/changes/10300-newFacility/00-weekWaste.sql +++ /dev/null @@ -1,28 +0,0 @@ -DROP PROCEDURE IF EXISTS `bs`.`weekWaste`; - -DELIMITER $$ -$$ -CREATE DEFINER = `root`@`%` PROCEDURE `bs`.`weekWaste__`() -BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - SUM(saleTotal) AS total, - SUM(saleWaste) AS dwindle - FROM bs.waste - WHERE year = vYear - AND week = vWeek - GROUP BY buyer - ) sub - ORDER BY percentage DESC; -END;$$ -DELIMITER ; - diff --git a/db/changes/10300-newFacility/00-weekWaste_byWorker.sql b/db/changes/10300-newFacility/00-weekWaste_byWorker.sql deleted file mode 100644 index ff660494f..000000000 --- a/db/changes/10300-newFacility/00-weekWaste_byWorker.sql +++ /dev/null @@ -1,32 +0,0 @@ -DROP PROCEDURE IF EXISTS `bs`.`weekWaste_byWorker`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `bs`.`weekWaste_byWorker__`(IN vWorkerFk INT) -BEGIN - - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE()); - - SELECT *, 100 * mermas / total AS porcentaje - FROM ( - SELECT ws.family, - SUM(ws.saleTotal) AS total, - SUM(ws.saleWaste) AS mermas - FROM bs.waste ws - JOIN vn.worker w ON w.user = ws.buyer - WHERE year = vYear - AND week = vWeek - AND w.id = vWorkerFk - GROUP BY family - ) sub - ORDER BY porcentaje DESC; -END;;$$ -DELIMITER ; - diff --git a/db/changes/10300-newFacility/00-weekWaste_getDetail.sql b/db/changes/10300-newFacility/00-weekWaste_getDetail.sql deleted file mode 100644 index 5cf107d24..000000000 --- a/db/changes/10300-newFacility/00-weekWaste_getDetail.sql +++ /dev/null @@ -1,30 +0,0 @@ -DROP PROCEDURE IF EXISTS `bs`.`weekWaste_getDetail`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `bs`.`weekWaste_getDetail__`() -BEGIN - DECLARE vLastWeek DATE; - DECLARE vWeek INT; - DECLARE vYear INT; - - SET vLastWeek = TIMESTAMPADD(WEEK, -1, CURDATE()); - SET vYear = YEAR(vLastWeek); - SET vWeek = WEEK(vLastWeek, 1); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - SUM(ws.saleTotal) AS total, - SUM(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = vYear - AND week = vWeek - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC; -END;$$ -DELIMITER ; - diff --git a/db/changes/10300-newFacility/01-waste.sql b/db/changes/10300-newFacility/01-waste.sql deleted file mode 100644 index b01f3b6df..000000000 --- a/db/changes/10300-newFacility/01-waste.sql +++ /dev/null @@ -1,21 +0,0 @@ -ALTER TABLE `bs`.`waste` - ADD itemFk INT NULL AFTER `family`; - -ALTER TABLE `bs`.`waste` - ADD itemTypeFk SMALLINT(5) UNSIGNED NULL AFTER `itemFk`; - -ALTER TABLE `bs`.`waste` - ADD CONSTRAINT waste_itemType_id - FOREIGN KEY (itemTypeFk) REFERENCES vn.itemType (id) - ON UPDATE CASCADE; - -ALTER TABLE `bs`.`waste` - ADD CONSTRAINT waste_item_id - FOREIGN KEY (itemFk) REFERENCES vn.item (id) - ON UPDATE CASCADE; - -ALTER TABLE `bs`.`waste` DROP PRIMARY KEY; - -ALTER TABLE `bs`.`waste` - ADD PRIMARY KEY (buyer, `year`, week, family, itemFk); - diff --git a/db/changes/10300-newFacility/02-waste_addSales.sql b/db/changes/10300-newFacility/02-waste_addSales.sql deleted file mode 100644 index ae9efd95b..000000000 --- a/db/changes/10300-newFacility/02-waste_addSales.sql +++ /dev/null @@ -1,37 +0,0 @@ -UPDATE `bs`.nightTask t SET t.`procedure` = 'waste_addSales' WHERE t.id = 54; - -DROP PROCEDURE IF EXISTS `bs`.`waste_Add`; - -DELIMITER $$ -$$ -CREATE - DEFINER = root@`%` PROCEDURE `bs`.`waste_addSales`() -BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = CURDATE(); - - REPLACE bs.waste - SELECT *, 100 * mermas / total as porcentaje - FROM ( - SELECT buyer, - year, - week, - family, - itemFk, - itemTypeFk, - floor(sum(value)) as total, - floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue - where year = vYear and week = vWeek - - GROUP BY family, itemFk - - ) sub - ORDER BY mermas DESC; -END;$$ -DELIMITER ; diff --git a/db/changes/10320-monitors/01-warehouse.sql b/db/changes/10320-monitors/01-warehouse.sql new file mode 100644 index 000000000..45e1c0c56 --- /dev/null +++ b/db/changes/10320-monitors/01-warehouse.sql @@ -0,0 +1,4 @@ +ALTER TABLE `vn`.`warehouse` + ADD `code` VARCHAR(3) NULL AFTER name; + +UPDATE `vn`.`warehouse` SET `code` = 'ALG' WHERE `id` = 60; \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 67f547c6d..b8f17d6ed 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,6 +1,6 @@ USE `util`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ @@ -22,7 +22,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10291',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10300',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -34,9 +34,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:49 +-- Dump completed on 2021-05-25 11:53:07 USE `account`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -68,7 +68,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(100,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64); +INSERT INTO `roleInherit` VALUES (1,1,2),(2,1,3),(3,1,70),(4,2,11),(5,3,11),(6,5,1),(7,5,21),(8,5,33),(124,5,76),(123,9,76),(9,9,100),(10,11,6),(11,13,1),(12,15,35),(143,15,49),(13,15,57),(114,15,76),(14,16,13),(15,16,15),(127,16,76),(16,17,20),(17,17,37),(18,17,39),(19,17,64),(145,17,67),(136,17,76),(20,18,1),(132,18,76),(21,19,21),(22,20,13),(23,20,16),(24,20,65),(134,20,76),(25,21,13),(26,21,18),(27,21,53),(131,21,76),(28,22,13),(29,22,21),(30,30,5),(31,30,20),(32,30,22),(33,30,53),(34,30,64),(118,30,76),(35,31,1),(36,32,1),(37,34,1),(38,34,13),(39,34,33),(40,35,1),(142,35,75),(129,35,76),(41,36,44),(42,36,47),(43,37,1),(139,37,74),(125,37,76),(44,38,37),(45,38,64),(126,38,76),(46,39,5),(47,39,21),(48,39,57),(115,39,76),(49,40,1),(50,40,49),(51,41,13),(52,41,35),(53,41,40),(135,41,76),(54,42,35),(55,42,49),(128,42,76),(56,43,13),(57,43,42),(58,44,1),(59,45,13),(60,45,44),(61,47,1),(62,48,13),(63,48,47),(64,49,36),(65,49,58),(66,50,13),(67,50,21),(68,50,35),(69,50,49),(70,50,57),(71,50,59),(133,50,76),(72,51,1),(140,51,74),(141,51,75),(73,52,13),(74,52,19),(75,52,35),(76,52,51),(137,52,76),(77,53,1),(78,54,1),(79,55,13),(80,55,54),(81,56,1),(82,57,13),(83,57,56),(138,57,76),(84,58,1),(85,59,13),(109,59,50),(87,60,5),(88,60,37),(89,60,50),(90,60,57),(130,60,76),(91,61,13),(92,61,36),(93,65,19),(94,65,35),(95,65,50),(117,65,76),(122,66,76),(96,66,100),(97,67,5),(98,67,37),(99,69,35),(100,69,47),(101,70,11),(144,70,76),(102,71,1),(103,71,58),(104,72,13),(105,72,18),(106,73,5),(108,73,19),(107,73,64); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -78,7 +78,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (33021,1,1),(33022,1,2),(33023,1,3),(33027,1,6),(33026,1,11),(33024,1,70),(33025,1,76),(32939,2,2),(32941,2,6),(32940,2,11),(32834,3,3),(32836,3,6),(32835,3,11),(32806,5,1),(32813,5,2),(32812,5,3),(32805,5,5),(32817,5,6),(32816,5,11),(32810,5,13),(32814,5,18),(32807,5,21),(32808,5,33),(32815,5,53),(32811,5,70),(32809,5,76),(33092,6,6),(32985,9,1),(32982,9,2),(32970,9,3),(32968,9,5),(32990,9,6),(32960,9,9),(32965,9,11),(33017,9,13),(32999,9,15),(33000,9,16),(32967,9,17),(33015,9,18),(33014,9,19),(33001,9,20),(33013,9,21),(33018,9,22),(32988,9,30),(32989,9,31),(32986,9,32),(32996,9,33),(32971,9,34),(32975,9,35),(33011,9,36),(32993,9,37),(32994,9,38),(32966,9,39),(32991,9,40),(32992,9,41),(32972,9,42),(32973,9,43),(32963,9,44),(32964,9,45),(32979,9,47),(32981,9,48),(33008,9,49),(33010,9,50),(33002,9,51),(33003,9,52),(32995,9,53),(32997,9,54),(32998,9,55),(32983,9,56),(32984,9,57),(33006,9,58),(33007,9,59),(33009,9,60),(33012,9,61),(33004,9,62),(32974,9,64),(33005,9,65),(33016,9,66),(32969,9,67),(32980,9,69),(33019,9,70),(32977,9,71),(32978,9,72),(32987,9,73),(33020,9,74),(32976,9,75),(32961,9,76),(32962,9,100),(32754,11,6),(32753,11,11),(33553,13,1),(33554,13,2),(33555,13,3),(33559,13,6),(33558,13,11),(33552,13,13),(33556,13,70),(33557,13,76),(33178,15,1),(33185,15,2),(33184,15,3),(33187,15,6),(33186,15,11),(33179,15,13),(33170,15,15),(33171,15,35),(33176,15,36),(33182,15,44),(33181,15,47),(33172,15,49),(33180,15,56),(33173,15,57),(33175,15,58),(33183,15,70),(33177,15,75),(33174,15,76),(33194,16,1),(33199,16,2),(33198,16,3),(33206,16,6),(33205,16,11),(33189,16,13),(33190,16,15),(33188,16,16),(33193,16,35),(33200,16,36),(33204,16,44),(33203,16,47),(33192,16,49),(33202,16,56),(33195,16,57),(33201,16,58),(33197,16,70),(33196,16,75),(33191,16,76),(32778,17,1),(32788,17,2),(32787,17,3),(32782,17,5),(32800,17,6),(32796,17,11),(32781,17,13),(32792,17,15),(32780,17,16),(32771,17,17),(32793,17,18),(32791,17,19),(32772,17,20),(32783,17,21),(32785,17,33),(32790,17,35),(32802,17,36),(32773,17,37),(32774,17,39),(32804,17,44),(32803,17,47),(32799,17,49),(32789,17,50),(32794,17,53),(32795,17,56),(32784,17,57),(32801,17,58),(32797,17,59),(32775,17,64),(32779,17,65),(32786,17,70),(32777,17,74),(32798,17,75),(32776,17,76),(33484,18,1),(33487,18,2),(33486,18,3),(33490,18,6),(33489,18,11),(33483,18,18),(33488,18,70),(33485,18,76),(33477,19,1),(33480,19,2),(33479,19,3),(33482,19,6),(33481,19,11),(33473,19,13),(33474,19,18),(33471,19,19),(33472,19,21),(33475,19,53),(33478,19,70),(33476,19,76),(33215,20,1),(33221,20,2),(33220,20,3),(33233,20,6),(33230,20,11),(33208,20,13),(33214,20,15),(33209,20,16),(33226,20,18),(33213,20,19),(33207,20,20),(33222,20,21),(33212,20,35),(33229,20,36),(33232,20,44),(33231,20,47),(33218,20,49),(33216,20,50),(33225,20,53),(33227,20,56),(33217,20,57),(33228,20,58),(33224,20,59),(33210,20,65),(33219,20,70),(33223,20,75),(33211,20,76),(33465,21,1),(33468,21,2),(33467,21,3),(33470,21,6),(33469,21,11),(33461,21,13),(33462,21,18),(33460,21,21),(33463,21,53),(33466,21,70),(33464,21,76),(33564,22,1),(33569,22,2),(33568,22,3),(33571,22,6),(33570,22,11),(33561,22,13),(33563,22,18),(33562,22,21),(33560,22,22),(33565,22,53),(33567,22,70),(33566,22,76),(33064,30,1),(33070,30,2),(33069,30,3),(33053,30,5),(33081,30,6),(33077,30,11),(33061,30,13),(33066,30,15),(33060,30,16),(33067,30,18),(33065,30,19),(33054,30,20),(33063,30,21),(33055,30,22),(33052,30,30),(33062,30,33),(33071,30,35),(33080,30,36),(33083,30,44),(33082,30,47),(33076,30,49),(33072,30,50),(33056,30,53),(33078,30,56),(33075,30,57),(33079,30,58),(33073,30,59),(33057,30,64),(33059,30,65),(33068,30,70),(33074,30,75),(33058,30,76),(33085,31,1),(33086,31,2),(33087,31,3),(33091,31,6),(33090,31,11),(33084,31,31),(33088,31,70),(33089,31,76),(33029,32,1),(33030,32,2),(33031,32,3),(33035,32,6),(33034,32,11),(33028,32,32),(33032,32,70),(33033,32,76),(33151,33,33),(32838,34,1),(32843,34,2),(32842,34,3),(32846,34,6),(32845,34,11),(32839,34,13),(32840,34,33),(32837,34,34),(32841,34,70),(32844,34,76),(32881,35,1),(32886,35,2),(32885,35,3),(32888,35,6),(32887,35,11),(32880,35,35),(32884,35,70),(32882,35,75),(32883,35,76),(33380,36,1),(33382,36,2),(33381,36,3),(33386,36,6),(33385,36,11),(33377,36,36),(33378,36,44),(33379,36,47),(33383,36,70),(33384,36,76),(33124,37,1),(33129,37,2),(33128,37,3),(33131,37,6),(33130,37,11),(33123,37,37),(33127,37,70),(33125,37,74),(33126,37,76),(33137,38,1),(33140,38,2),(33139,38,3),(33142,38,6),(33141,38,11),(33133,38,37),(33132,38,38),(33134,38,64),(33138,38,70),(33136,38,74),(33135,38,76),(32763,39,1),(32768,39,2),(32767,39,3),(32756,39,5),(32770,39,6),(32769,39,11),(32761,39,13),(32760,39,18),(32757,39,21),(32762,39,33),(32755,39,39),(32764,39,53),(32765,39,56),(32758,39,57),(32766,39,70),(32759,39,76),(33094,40,1),(33097,40,2),(33096,40,3),(33105,40,6),(33104,40,11),(33099,40,36),(33093,40,40),(33102,40,44),(33101,40,47),(33095,40,49),(33100,40,58),(33098,40,70),(33103,40,76),(33113,41,1),(33117,41,2),(33116,41,3),(33122,41,6),(33121,41,11),(33107,41,13),(33108,41,35),(33114,41,36),(33109,41,40),(33106,41,41),(33120,41,44),(33119,41,47),(33111,41,49),(33118,41,58),(33115,41,70),(33112,41,75),(33110,41,76),(32853,42,1),(32858,42,2),(32857,42,3),(32861,42,6),(32860,42,11),(32848,42,35),(32851,42,36),(32847,42,42),(32855,42,44),(32859,42,47),(32849,42,49),(32854,42,58),(32856,42,70),(32852,42,75),(32850,42,76),(32866,43,1),(32872,43,2),(32871,43,3),(32878,43,6),(32877,43,11),(32863,43,13),(32865,43,35),(32873,43,36),(32864,43,42),(32862,43,43),(32876,43,44),(32875,43,47),(32867,43,49),(32874,43,58),(32870,43,70),(32869,43,75),(32868,43,76),(32736,44,1),(32737,44,2),(32738,44,3),(32742,44,6),(32741,44,11),(32735,44,44),(32739,44,70),(32740,44,76),(32746,45,1),(32748,45,2),(32747,45,3),(32752,45,6),(32751,45,11),(32744,45,13),(32745,45,44),(32743,45,45),(32749,45,70),(32750,45,76),(32911,47,1),(32912,47,2),(32913,47,3),(32917,47,6),(32916,47,11),(32910,47,47),(32914,47,70),(32915,47,76),(32932,48,1),(32934,48,2),(32933,48,3),(32938,48,6),(32937,48,11),(32930,48,13),(32931,48,47),(32929,48,48),(32935,48,70),(32936,48,76),(33321,49,1),(33324,49,2),(33323,49,3),(33327,49,6),(33326,49,11),(33317,49,36),(33320,49,44),(33319,49,47),(33316,49,49),(33318,49,58),(33322,49,70),(33325,49,76),(33369,50,1),(33374,50,2),(33373,50,3),(33376,50,6),(33375,50,11),(33356,50,13),(33368,50,18),(33357,50,21),(33358,50,35),(33365,50,36),(33371,50,44),(33370,50,47),(33359,50,49),(33355,50,50),(33367,50,53),(33363,50,56),(33360,50,57),(33364,50,58),(33361,50,59),(33372,50,70),(33366,50,75),(33362,50,76),(33235,51,1),(33240,51,2),(33239,51,3),(33243,51,6),(33242,51,11),(33234,51,51),(33238,51,70),(33236,51,74),(33237,51,75),(33241,51,76),(33253,52,1),(33258,52,2),(33257,52,3),(33260,52,6),(33259,52,11),(33245,52,13),(33255,52,18),(33246,52,19),(33252,52,21),(33247,52,35),(33248,52,51),(33244,52,52),(33254,52,53),(33256,52,70),(33250,52,74),(33251,52,75),(33249,52,76),(33144,53,1),(33145,53,2),(33146,53,3),(33150,53,6),(33149,53,11),(33143,53,53),(33147,53,70),(33148,53,76),(33153,54,1),(33154,54,2),(33155,54,3),(33159,54,6),(33158,54,11),(33152,54,54),(33156,54,70),(33157,54,76),(33163,55,1),(33165,55,2),(33164,55,3),(33169,55,6),(33168,55,11),(33161,55,13),(33162,55,54),(33160,55,55),(33166,55,70),(33167,55,76),(32943,56,1),(32944,56,2),(32945,56,3),(32949,56,6),(32948,56,11),(32942,56,56),(32946,56,70),(32947,56,76),(32954,57,1),(32957,57,2),(32956,57,3),(32959,57,6),(32958,57,11),(32951,57,13),(32952,57,56),(32950,57,57),(32955,57,70),(32953,57,76),(33287,58,1),(33288,58,2),(33289,58,3),(33293,58,6),(33292,58,11),(33286,58,58),(33290,58,70),(33291,58,76),(33298,59,1),(33308,59,2),(33307,59,3),(33315,59,6),(33314,59,11),(33295,59,13),(33305,59,18),(33297,59,21),(33299,59,35),(33309,59,36),(33313,59,44),(33312,59,47),(33300,59,49),(33296,59,50),(33304,59,53),(33311,59,56),(33301,59,57),(33310,59,58),(33294,59,59),(33306,59,70),(33303,59,75),(33302,59,76),(33338,60,1),(33350,60,2),(33349,60,3),(33329,60,5),(33354,60,6),(33353,60,11),(33334,60,13),(33347,60,18),(33337,60,21),(33336,60,33),(33339,60,35),(33344,60,36),(33330,60,37),(33352,60,44),(33351,60,47),(33340,60,49),(33331,60,50),(33346,60,53),(33342,60,56),(33332,60,57),(33343,60,58),(33341,60,59),(33328,60,60),(33348,60,70),(33335,60,74),(33345,60,75),(33333,60,76),(33391,61,1),(33395,61,2),(33394,61,3),(33398,61,6),(33397,61,11),(33388,61,13),(33389,61,36),(33390,61,44),(33392,61,47),(33387,61,61),(33393,61,70),(33396,61,76),(33261,62,62),(32879,64,64),(33269,65,1),(33278,65,2),(33277,65,3),(33285,65,6),(33284,65,11),(33267,65,13),(33280,65,18),(33263,65,19),(33270,65,21),(33264,65,35),(33275,65,36),(33283,65,44),(33282,65,47),(33271,65,49),(33265,65,50),(33279,65,53),(33281,65,56),(33272,65,57),(33274,65,58),(33273,65,59),(33262,65,65),(33276,65,70),(33268,65,75),(33266,65,76),(33517,66,1),(33513,66,2),(33501,66,3),(33499,66,5),(33522,66,6),(33516,66,9),(33496,66,11),(33548,66,13),(33531,66,15),(33532,66,16),(33498,66,17),(33547,66,18),(33546,66,19),(33533,66,20),(33545,66,21),(33549,66,22),(33520,66,30),(33521,66,31),(33518,66,32),(33528,66,33),(33502,66,34),(33506,66,35),(33543,66,36),(33525,66,37),(33526,66,38),(33497,66,39),(33523,66,40),(33524,66,41),(33503,66,42),(33504,66,43),(33494,66,44),(33495,66,45),(33510,66,47),(33512,66,48),(33540,66,49),(33542,66,50),(33534,66,51),(33535,66,52),(33527,66,53),(33529,66,54),(33530,66,55),(33514,66,56),(33515,66,57),(33538,66,58),(33539,66,59),(33541,66,60),(33544,66,61),(33536,66,62),(33505,66,64),(33537,66,65),(33491,66,66),(33500,66,67),(33511,66,69),(33550,66,70),(33508,66,71),(33509,66,72),(33519,66,73),(33551,66,74),(33507,66,75),(33492,66,76),(33493,66,100),(32822,67,1),(32830,67,2),(32829,67,3),(32819,67,5),(32833,67,6),(32832,67,11),(32827,67,13),(32826,67,18),(32821,67,21),(32823,67,33),(32820,67,37),(32831,67,53),(32818,67,67),(32828,67,70),(32825,67,74),(32824,67,76),(32922,69,1),(32926,69,2),(32925,69,3),(32928,69,6),(32927,69,11),(32919,69,35),(32920,69,47),(32918,69,69),(32924,69,70),(32921,69,75),(32923,69,76),(33575,70,6),(33573,70,11),(33572,70,70),(33574,70,76),(32892,71,1),(32895,71,2),(32894,71,3),(32899,71,6),(32898,71,11),(32893,71,58),(32896,71,70),(32891,71,71),(32897,71,76),(32904,72,1),(32906,72,2),(32905,72,3),(32909,72,6),(32908,72,11),(32901,72,13),(32902,72,18),(32907,72,70),(32900,72,72),(32903,72,76),(33042,73,1),(33047,73,2),(33046,73,3),(33037,73,5),(33051,73,6),(33050,73,11),(33044,73,13),(33048,73,18),(33038,73,19),(33041,73,21),(33040,73,33),(33049,73,53),(33039,73,64),(33045,73,70),(33036,73,73),(33043,73,76),(33576,74,74),(32889,75,75),(32890,76,76),(33424,100,1),(33420,100,2),(33407,100,3),(33405,100,5),(33429,100,6),(33423,100,9),(33402,100,11),(33456,100,13),(33438,100,15),(33439,100,16),(33404,100,17),(33454,100,18),(33453,100,19),(33440,100,20),(33452,100,21),(33457,100,22),(33427,100,30),(33428,100,31),(33425,100,32),(33435,100,33),(33408,100,34),(33412,100,35),(33450,100,36),(33432,100,37),(33433,100,38),(33403,100,39),(33430,100,40),(33431,100,41),(33409,100,42),(33410,100,43),(33400,100,44),(33401,100,45),(33417,100,47),(33419,100,48),(33447,100,49),(33449,100,50),(33441,100,51),(33442,100,52),(33434,100,53),(33436,100,54),(33437,100,55),(33421,100,56),(33422,100,57),(33445,100,58),(33446,100,59),(33448,100,60),(33451,100,61),(33443,100,62),(33411,100,64),(33444,100,65),(33455,100,66),(33406,100,67),(33418,100,69),(33458,100,70),(33415,100,71),(33416,100,72),(33426,100,73),(33459,100,74),(33413,100,75),(33414,100,76),(33399,100,100); +INSERT INTO `roleRole` VALUES (37416,1,1),(37417,1,2),(37418,1,3),(37422,1,6),(37421,1,11),(37419,1,70),(37420,1,76),(37334,2,2),(37336,2,6),(37335,2,11),(37229,3,3),(37231,3,6),(37230,3,11),(37201,5,1),(37208,5,2),(37207,5,3),(37200,5,5),(37212,5,6),(37211,5,11),(37205,5,13),(37209,5,18),(37202,5,21),(37203,5,33),(37210,5,53),(37206,5,70),(37204,5,76),(37487,6,6),(37380,9,1),(37377,9,2),(37365,9,3),(37363,9,5),(37385,9,6),(37355,9,9),(37360,9,11),(37412,9,13),(37394,9,15),(37395,9,16),(37362,9,17),(37410,9,18),(37409,9,19),(37396,9,20),(37408,9,21),(37413,9,22),(37383,9,30),(37384,9,31),(37381,9,32),(37391,9,33),(37366,9,34),(37370,9,35),(37406,9,36),(37388,9,37),(37389,9,38),(37361,9,39),(37386,9,40),(37387,9,41),(37367,9,42),(37368,9,43),(37358,9,44),(37359,9,45),(37374,9,47),(37376,9,48),(37403,9,49),(37405,9,50),(37397,9,51),(37398,9,52),(37390,9,53),(37392,9,54),(37393,9,55),(37378,9,56),(37379,9,57),(37401,9,58),(37402,9,59),(37404,9,60),(37407,9,61),(37399,9,62),(37369,9,64),(37400,9,65),(37411,9,66),(37364,9,67),(37375,9,69),(37414,9,70),(37372,9,71),(37373,9,72),(37382,9,73),(37415,9,74),(37371,9,75),(37356,9,76),(37357,9,100),(37148,11,6),(37147,11,11),(37948,13,1),(37949,13,2),(37950,13,3),(37954,13,6),(37953,13,11),(37947,13,13),(37951,13,70),(37952,13,76),(37573,15,1),(37580,15,2),(37579,15,3),(37582,15,6),(37581,15,11),(37574,15,13),(37565,15,15),(37566,15,35),(37571,15,36),(37577,15,44),(37576,15,47),(37567,15,49),(37575,15,56),(37568,15,57),(37570,15,58),(37578,15,70),(37572,15,75),(37569,15,76),(37589,16,1),(37594,16,2),(37593,16,3),(37601,16,6),(37600,16,11),(37584,16,13),(37585,16,15),(37583,16,16),(37588,16,35),(37595,16,36),(37599,16,44),(37598,16,47),(37587,16,49),(37597,16,56),(37590,16,57),(37596,16,58),(37592,16,70),(37591,16,75),(37586,16,76),(37174,17,1),(37183,17,2),(37182,17,3),(37172,17,5),(37195,17,6),(37191,17,11),(37177,17,13),(37187,17,15),(37176,17,16),(37165,17,17),(37188,17,18),(37186,17,19),(37166,17,20),(37178,17,21),(37180,17,33),(37185,17,35),(37197,17,36),(37167,17,37),(37168,17,39),(37199,17,44),(37198,17,47),(37194,17,49),(37184,17,50),(37189,17,53),(37190,17,56),(37179,17,57),(37196,17,58),(37192,17,59),(37169,17,64),(37175,17,65),(37170,17,67),(37181,17,70),(37173,17,74),(37193,17,75),(37171,17,76),(37879,18,1),(37882,18,2),(37881,18,3),(37885,18,6),(37884,18,11),(37878,18,18),(37883,18,70),(37880,18,76),(37872,19,1),(37875,19,2),(37874,19,3),(37877,19,6),(37876,19,11),(37868,19,13),(37869,19,18),(37866,19,19),(37867,19,21),(37870,19,53),(37873,19,70),(37871,19,76),(37610,20,1),(37616,20,2),(37615,20,3),(37628,20,6),(37625,20,11),(37603,20,13),(37609,20,15),(37604,20,16),(37621,20,18),(37608,20,19),(37602,20,20),(37617,20,21),(37607,20,35),(37624,20,36),(37627,20,44),(37626,20,47),(37613,20,49),(37611,20,50),(37620,20,53),(37622,20,56),(37612,20,57),(37623,20,58),(37619,20,59),(37605,20,65),(37614,20,70),(37618,20,75),(37606,20,76),(37860,21,1),(37863,21,2),(37862,21,3),(37865,21,6),(37864,21,11),(37856,21,13),(37857,21,18),(37855,21,21),(37858,21,53),(37861,21,70),(37859,21,76),(37959,22,1),(37964,22,2),(37963,22,3),(37966,22,6),(37965,22,11),(37956,22,13),(37958,22,18),(37957,22,21),(37955,22,22),(37960,22,53),(37962,22,70),(37961,22,76),(37459,30,1),(37465,30,2),(37464,30,3),(37448,30,5),(37476,30,6),(37472,30,11),(37456,30,13),(37461,30,15),(37455,30,16),(37462,30,18),(37460,30,19),(37449,30,20),(37458,30,21),(37450,30,22),(37447,30,30),(37457,30,33),(37466,30,35),(37475,30,36),(37478,30,44),(37477,30,47),(37471,30,49),(37467,30,50),(37451,30,53),(37473,30,56),(37470,30,57),(37474,30,58),(37468,30,59),(37452,30,64),(37454,30,65),(37463,30,70),(37469,30,75),(37453,30,76),(37480,31,1),(37481,31,2),(37482,31,3),(37486,31,6),(37485,31,11),(37479,31,31),(37483,31,70),(37484,31,76),(37424,32,1),(37425,32,2),(37426,32,3),(37430,32,6),(37429,32,11),(37423,32,32),(37427,32,70),(37428,32,76),(37546,33,33),(37233,34,1),(37238,34,2),(37237,34,3),(37241,34,6),(37240,34,11),(37234,34,13),(37235,34,33),(37232,34,34),(37236,34,70),(37239,34,76),(37276,35,1),(37281,35,2),(37280,35,3),(37283,35,6),(37282,35,11),(37275,35,35),(37279,35,70),(37277,35,75),(37278,35,76),(37775,36,1),(37777,36,2),(37776,36,3),(37781,36,6),(37780,36,11),(37772,36,36),(37773,36,44),(37774,36,47),(37778,36,70),(37779,36,76),(37519,37,1),(37524,37,2),(37523,37,3),(37526,37,6),(37525,37,11),(37518,37,37),(37522,37,70),(37520,37,74),(37521,37,76),(37532,38,1),(37535,38,2),(37534,38,3),(37537,38,6),(37536,38,11),(37528,38,37),(37527,38,38),(37529,38,64),(37533,38,70),(37531,38,74),(37530,38,76),(37157,39,1),(37162,39,2),(37161,39,3),(37150,39,5),(37164,39,6),(37163,39,11),(37155,39,13),(37154,39,18),(37151,39,21),(37156,39,33),(37149,39,39),(37158,39,53),(37159,39,56),(37152,39,57),(37160,39,70),(37153,39,76),(37489,40,1),(37492,40,2),(37491,40,3),(37500,40,6),(37499,40,11),(37494,40,36),(37488,40,40),(37497,40,44),(37496,40,47),(37490,40,49),(37495,40,58),(37493,40,70),(37498,40,76),(37508,41,1),(37512,41,2),(37511,41,3),(37517,41,6),(37516,41,11),(37502,41,13),(37503,41,35),(37509,41,36),(37504,41,40),(37501,41,41),(37515,41,44),(37514,41,47),(37506,41,49),(37513,41,58),(37510,41,70),(37507,41,75),(37505,41,76),(37248,42,1),(37253,42,2),(37252,42,3),(37256,42,6),(37255,42,11),(37243,42,35),(37246,42,36),(37242,42,42),(37250,42,44),(37254,42,47),(37244,42,49),(37249,42,58),(37251,42,70),(37247,42,75),(37245,42,76),(37261,43,1),(37267,43,2),(37266,43,3),(37273,43,6),(37272,43,11),(37258,43,13),(37260,43,35),(37268,43,36),(37259,43,42),(37257,43,43),(37271,43,44),(37270,43,47),(37262,43,49),(37269,43,58),(37265,43,70),(37264,43,75),(37263,43,76),(37130,44,1),(37131,44,2),(37132,44,3),(37136,44,6),(37135,44,11),(37129,44,44),(37133,44,70),(37134,44,76),(37140,45,1),(37142,45,2),(37141,45,3),(37146,45,6),(37145,45,11),(37138,45,13),(37139,45,44),(37137,45,45),(37143,45,70),(37144,45,76),(37306,47,1),(37307,47,2),(37308,47,3),(37312,47,6),(37311,47,11),(37305,47,47),(37309,47,70),(37310,47,76),(37327,48,1),(37329,48,2),(37328,48,3),(37333,48,6),(37332,48,11),(37325,48,13),(37326,48,47),(37324,48,48),(37330,48,70),(37331,48,76),(37716,49,1),(37719,49,2),(37718,49,3),(37722,49,6),(37721,49,11),(37712,49,36),(37715,49,44),(37714,49,47),(37711,49,49),(37713,49,58),(37717,49,70),(37720,49,76),(37764,50,1),(37769,50,2),(37768,50,3),(37771,50,6),(37770,50,11),(37751,50,13),(37763,50,18),(37752,50,21),(37753,50,35),(37760,50,36),(37766,50,44),(37765,50,47),(37754,50,49),(37750,50,50),(37762,50,53),(37758,50,56),(37755,50,57),(37759,50,58),(37756,50,59),(37767,50,70),(37761,50,75),(37757,50,76),(37630,51,1),(37635,51,2),(37634,51,3),(37638,51,6),(37637,51,11),(37629,51,51),(37633,51,70),(37631,51,74),(37632,51,75),(37636,51,76),(37648,52,1),(37653,52,2),(37652,52,3),(37655,52,6),(37654,52,11),(37640,52,13),(37650,52,18),(37641,52,19),(37647,52,21),(37642,52,35),(37643,52,51),(37639,52,52),(37649,52,53),(37651,52,70),(37645,52,74),(37646,52,75),(37644,52,76),(37539,53,1),(37540,53,2),(37541,53,3),(37545,53,6),(37544,53,11),(37538,53,53),(37542,53,70),(37543,53,76),(37548,54,1),(37549,54,2),(37550,54,3),(37554,54,6),(37553,54,11),(37547,54,54),(37551,54,70),(37552,54,76),(37558,55,1),(37560,55,2),(37559,55,3),(37564,55,6),(37563,55,11),(37556,55,13),(37557,55,54),(37555,55,55),(37561,55,70),(37562,55,76),(37338,56,1),(37339,56,2),(37340,56,3),(37344,56,6),(37343,56,11),(37337,56,56),(37341,56,70),(37342,56,76),(37349,57,1),(37352,57,2),(37351,57,3),(37354,57,6),(37353,57,11),(37346,57,13),(37347,57,56),(37345,57,57),(37350,57,70),(37348,57,76),(37682,58,1),(37683,58,2),(37684,58,3),(37688,58,6),(37687,58,11),(37681,58,58),(37685,58,70),(37686,58,76),(37693,59,1),(37703,59,2),(37702,59,3),(37710,59,6),(37709,59,11),(37690,59,13),(37700,59,18),(37692,59,21),(37694,59,35),(37704,59,36),(37708,59,44),(37707,59,47),(37695,59,49),(37691,59,50),(37699,59,53),(37706,59,56),(37696,59,57),(37705,59,58),(37689,59,59),(37701,59,70),(37698,59,75),(37697,59,76),(37733,60,1),(37745,60,2),(37744,60,3),(37724,60,5),(37749,60,6),(37748,60,11),(37729,60,13),(37742,60,18),(37732,60,21),(37731,60,33),(37734,60,35),(37739,60,36),(37725,60,37),(37747,60,44),(37746,60,47),(37735,60,49),(37726,60,50),(37741,60,53),(37737,60,56),(37727,60,57),(37738,60,58),(37736,60,59),(37723,60,60),(37743,60,70),(37730,60,74),(37740,60,75),(37728,60,76),(37786,61,1),(37790,61,2),(37789,61,3),(37793,61,6),(37792,61,11),(37783,61,13),(37784,61,36),(37785,61,44),(37787,61,47),(37782,61,61),(37788,61,70),(37791,61,76),(37656,62,62),(37274,64,64),(37664,65,1),(37673,65,2),(37672,65,3),(37680,65,6),(37679,65,11),(37662,65,13),(37675,65,18),(37658,65,19),(37665,65,21),(37659,65,35),(37670,65,36),(37678,65,44),(37677,65,47),(37666,65,49),(37660,65,50),(37674,65,53),(37676,65,56),(37667,65,57),(37669,65,58),(37668,65,59),(37657,65,65),(37671,65,70),(37663,65,75),(37661,65,76),(37912,66,1),(37908,66,2),(37896,66,3),(37894,66,5),(37917,66,6),(37911,66,9),(37891,66,11),(37943,66,13),(37926,66,15),(37927,66,16),(37893,66,17),(37942,66,18),(37941,66,19),(37928,66,20),(37940,66,21),(37944,66,22),(37915,66,30),(37916,66,31),(37913,66,32),(37923,66,33),(37897,66,34),(37901,66,35),(37938,66,36),(37920,66,37),(37921,66,38),(37892,66,39),(37918,66,40),(37919,66,41),(37898,66,42),(37899,66,43),(37889,66,44),(37890,66,45),(37905,66,47),(37907,66,48),(37935,66,49),(37937,66,50),(37929,66,51),(37930,66,52),(37922,66,53),(37924,66,54),(37925,66,55),(37909,66,56),(37910,66,57),(37933,66,58),(37934,66,59),(37936,66,60),(37939,66,61),(37931,66,62),(37900,66,64),(37932,66,65),(37886,66,66),(37895,66,67),(37906,66,69),(37945,66,70),(37903,66,71),(37904,66,72),(37914,66,73),(37946,66,74),(37902,66,75),(37887,66,76),(37888,66,100),(37217,67,1),(37225,67,2),(37224,67,3),(37214,67,5),(37228,67,6),(37227,67,11),(37222,67,13),(37221,67,18),(37216,67,21),(37218,67,33),(37215,67,37),(37226,67,53),(37213,67,67),(37223,67,70),(37220,67,74),(37219,67,76),(37317,69,1),(37321,69,2),(37320,69,3),(37323,69,6),(37322,69,11),(37314,69,35),(37315,69,47),(37313,69,69),(37319,69,70),(37316,69,75),(37318,69,76),(37970,70,6),(37968,70,11),(37967,70,70),(37969,70,76),(37287,71,1),(37290,71,2),(37289,71,3),(37294,71,6),(37293,71,11),(37288,71,58),(37291,71,70),(37286,71,71),(37292,71,76),(37299,72,1),(37301,72,2),(37300,72,3),(37304,72,6),(37303,72,11),(37296,72,13),(37297,72,18),(37302,72,70),(37295,72,72),(37298,72,76),(37437,73,1),(37442,73,2),(37441,73,3),(37432,73,5),(37446,73,6),(37445,73,11),(37439,73,13),(37443,73,18),(37433,73,19),(37436,73,21),(37435,73,33),(37444,73,53),(37434,73,64),(37440,73,70),(37431,73,73),(37438,73,76),(37971,74,74),(37284,75,75),(37285,76,76),(37819,100,1),(37815,100,2),(37802,100,3),(37800,100,5),(37824,100,6),(37818,100,9),(37797,100,11),(37851,100,13),(37833,100,15),(37834,100,16),(37799,100,17),(37849,100,18),(37848,100,19),(37835,100,20),(37847,100,21),(37852,100,22),(37822,100,30),(37823,100,31),(37820,100,32),(37830,100,33),(37803,100,34),(37807,100,35),(37845,100,36),(37827,100,37),(37828,100,38),(37798,100,39),(37825,100,40),(37826,100,41),(37804,100,42),(37805,100,43),(37795,100,44),(37796,100,45),(37812,100,47),(37814,100,48),(37842,100,49),(37844,100,50),(37836,100,51),(37837,100,52),(37829,100,53),(37831,100,54),(37832,100,55),(37816,100,56),(37817,100,57),(37840,100,58),(37841,100,59),(37843,100,60),(37846,100,61),(37838,100,62),(37806,100,64),(37839,100,65),(37850,100,66),(37801,100,67),(37813,100,69),(37853,100,70),(37810,100,71),(37811,100,72),(37821,100,73),(37854,100,74),(37808,100,75),(37809,100,76),(37794,100,100); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; @@ -120,9 +120,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:49 +-- Dump completed on 2021-05-25 11:53:07 USE `salix`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ @@ -176,9 +176,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:50 +-- Dump completed on 2021-05-25 11:53:08 USE `vn`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ @@ -310,7 +310,7 @@ UNLOCK TABLES; LOCK TABLES `claimReason` WRITE; /*!40000 ALTER TABLE `claimReason` DISABLE KEYS */; -INSERT INTO `claimReason` VALUES (1,'Prisas'),(2,'Novato'),(3,'Exceso de confianza'),(4,'Exceso de celo'),(5,'Indiferencia'),(6,'Extraviado o Hurto'),(7,'Incompetencia'),(8,'Ubicación erronea'),(9,'Dat.Inctos/Pak.conf'),(10,'Datos duplicados'),(11,'Fallo stock'),(12,'Innovación'),(13,'Distracción'),(15,'Portes indebidos'),(16,'Baja calidad'),(17,'Defectuoso'),(19,'Endiñado'),(20,'Calor'),(21,'Frio'),(22,'Cambiado'),(24,'Cansancio'),(25,'Mal etiquetado'),(26,'Cantidad malentendido'),(30,'No revisado'),(34,'Error fotografia'),(40,'Fallo Personal VN'),(41,'Fallo Personal Cliente'),(42,'Otros'),(43,'Precio alto'),(44,'Abuso de confianza'),(45,'Retraso Agencia'),(46,'Delicado'); +INSERT INTO `claimReason` VALUES (1,'Prisas',0),(2,'Novato',0),(3,'Exceso de confianza',0),(4,'Exceso de celo',0),(5,'Indiferencia',0),(6,'Extraviado o Hurto',0),(7,'Incompetencia',0),(8,'Ubicación erronea',0),(9,'Dat.Inctos/Pak.conf',0),(10,'Datos duplicados',0),(11,'Fallo stock',0),(12,'Innovación',0),(13,'Distracción',1),(15,'Portes indebidos',0),(16,'Baja calidad',0),(17,'Defectuoso',0),(19,'Endiñado',0),(20,'Calor',0),(21,'Frio',0),(22,'Cambiado',0),(24,'Cansancio',1),(25,'Mal etiquetado',1),(26,'Cantidad malentendido',0),(30,'No revisado',1),(34,'Error fotografia',0),(40,'Fallo Personal VN',0),(41,'Fallo Personal Cliente',0),(42,'Otros',0),(43,'Precio alto',0),(44,'Abuso de confianza',0),(45,'Retraso Agencia',0),(46,'Delicado',0); /*!40000 ALTER TABLE `claimReason` ENABLE KEYS */; UNLOCK TABLES; @@ -350,7 +350,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1),(2,'Libre',2,0,'FREE',NULL,2,1,0,0,0,1,0,4,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0),(4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0),(5,'Preparación',6,1,'ON_PREPARATION',7,5,0,0,0,2,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0),(11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0),(20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0,0,4,1),(23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1),(25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0,0,2,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,0,0,0,1,1,1,3,0),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,0,0,1,1,0,1,3,0),(30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0),(31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,3,0),(32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0),(33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0),(34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1),(35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -370,7 +370,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL),(43,NULL,'VENTAS',55,76,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es'),(44,NULL,'GERENCIA',77,78,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL),(45,NULL,'LOGISTICA',79,80,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL),(46,NULL,'REPARTO',81,84,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,0,NULL),(48,NULL,'ALMACENAJE',85,86,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(49,NULL,'PROPIEDAD',87,88,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL),(52,NULL,'CARGA AEREA',89,90,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',91,92,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL),(54,NULL,'ORNAMENTALES',93,94,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL),(55,NULL,'TALLER NATURAL',95,96,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL),(56,NULL,'TALLER ARTIFICIAL',97,98,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL),(58,NULL,'CAMPOS',99,100,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL),(59,NULL,'MANTENIMIENTO',101,102,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL),(60,NULL,'RECLAMACIONES',103,104,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL),(61,NULL,'VNH',105,106,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL),(66,NULL,'VERDNAMADRID',107,108,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL),(69,NULL,'VERDNABARNA',109,110,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL),(77,NULL,'PALETIZADO',82,83,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL),(86,NULL,'LIMPIEZA',111,112,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL),(89,NULL,'COORDINACION',113,114,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(90,NULL,'TRAILER',115,116,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL),(93,NULL,'CONFECCION',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL),(124,NULL,'CONTROL INTERNO',119,120,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL); +INSERT INTO `department` VALUES (1,NULL,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(22,NULL,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL,1,NULL),(23,NULL,'CAMARA',14,19,NULL,72,604,2,6,1,0,1,2,37,'/37/',NULL,0,NULL),(31,'IT','INFORMATICA',5,6,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica-cau',1,NULL),(34,NULL,'CONTABILIDAD',7,8,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(35,NULL,'FINANZAS',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(36,NULL,'LABORAL',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL),(37,NULL,'PRODUCCION',13,52,NULL,72,230,3,11,1,0,0,17,NULL,'/',NULL,0,NULL),(38,NULL,'SACADO',20,21,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL,0,NULL),(39,NULL,'ENCAJADO',22,23,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL,0,NULL),(41,NULL,'ADMINISTRACION',53,54,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL,1,NULL),(43,NULL,'VENTAS',55,76,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL,1,'direccioncomercial@verdnatura.es'),(44,NULL,'GERENCIA',77,78,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL,0,NULL),(45,NULL,'LOGISTICA',79,80,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL,1,NULL),(46,NULL,'REPARTO',81,84,NULL,72,659,3,10,0,0,0,1,NULL,'/',NULL,1,NULL),(48,NULL,'ALMACENAJE',85,86,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(49,NULL,'PROPIEDAD',87,88,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL,0,NULL),(52,NULL,'CARGA AEREA',89,90,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL,0,NULL),(53,NULL,'MARKETING Y COMUNICACIÓN',91,92,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL,1,NULL),(54,NULL,'ORNAMENTALES',93,94,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL,0,NULL),(55,NULL,'TALLER NATURAL',95,96,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL,0,NULL),(56,NULL,'TALLER ARTIFICIAL',97,98,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL,0,NULL),(58,NULL,'CAMPOS',99,100,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL,0,NULL),(59,NULL,'MANTENIMIENTO',101,102,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL,0,NULL),(60,NULL,'RECLAMACIONES',103,104,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL,1,NULL),(61,NULL,'VNH',105,106,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL,0,NULL),(63,NULL,'VENTAS FRANCIA',56,57,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL,0,NULL),(66,NULL,'VERDNAMADRID',107,108,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL,0,NULL),(68,NULL,'COMPLEMENTOS',24,25,NULL,72,617,3,26,1,0,1,0,37,'/37/',NULL,0,NULL),(69,NULL,'VERDNABARNA',109,110,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL,0,NULL),(77,NULL,'PALETIZADO',82,83,NULL,72,230,4,15,1,0,1,0,46,'/46/',NULL,0,NULL),(80,NULL,'EQUIPO J VALLES',58,59,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo',1,NULL),(86,NULL,'LIMPIEZA',111,112,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL,0,NULL),(89,NULL,'COORDINACION',113,114,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL,0,NULL),(90,NULL,'TRAILER',115,116,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(91,NULL,'ARTIFICIAL',26,27,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(92,NULL,'EQUIPO SILVERIO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo',1,NULL),(93,NULL,'CONFECCION',117,118,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,0,NULL),(94,NULL,'EQUIPO J BROCAL',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo',1,NULL),(95,NULL,'EQUIPO C ZAMBRANO',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo',1,NULL),(96,NULL,'EQUIPO C LOPEZ',66,67,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo',1,NULL),(98,NULL,'EQUIPO RODRIGO',68,69,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo',1,NULL),(101,NULL,'EQUIPO J IBAÑEZ',70,71,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo',1,NULL),(102,NULL,'EQ ROJO FV RUBEN C',28,29,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(103,NULL,'EQ AZUL FV A FOLQUES',30,31,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(104,NULL,'EQ AMARILLO FV NORMAN G',32,33,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(105,NULL,'EQ MORADO FV MATOU',34,35,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(106,NULL,'EQ VERDE PCA KEVIN GIMENEZ',36,37,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(107,NULL,'EQ NARANJA PCA RUBEN ZANON',38,39,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(110,NULL,'EQ ROSA PCA J BONDIA',40,41,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(111,NULL,'EQ REPONEDOR CAJAS',42,43,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(112,NULL,'CAMARA EQ EDGAR LLEO',15,16,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(113,NULL,'CAMARA EQ MARC ROCA',17,18,NULL,0,NULL,NULL,NULL,1,0,2,0,23,'/37/23/',NULL,0,NULL),(114,NULL,'EQ MARRON PCA JL NUEVO',44,45,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(115,NULL,'EQUIPO CLAUDI',72,73,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','csr_equipo',1,NULL),(120,NULL,'PCA PRODUCCION',46,47,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(121,NULL,'FV PRODUCCION',48,49,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(122,NULL,'PCA ALMACEN',50,51,NULL,0,NULL,NULL,NULL,1,0,1,0,37,'/37/',NULL,0,NULL),(123,NULL,'EQUIPO ELENA BASCUÑANA',74,75,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','ebt_equipo',1,NULL),(124,NULL,'CONTROL INTERNO',119,120,NULL,72,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL,1,NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -380,7 +380,7 @@ UNLOCK TABLES; LOCK TABLES `component` WRITE; /*!40000 ALTER TABLE `component` DISABLE KEYS */; -INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices'),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay'),(15,'reparto',6,NULL,NULL,1,'delivery'),(17,'recobro',5,NULL,NULL,1,'debtCollection'),(21,'ajuste',11,NULL,NULL,1,'adjustment'),(22,'venta por paquete',9,1,NULL,0,'salePerPackage'),(23,'venta por caja',9,2,NULL,0,'salePerBox'),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue'),(29,'margen',4,NULL,NULL,1,'margin'),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount'),(33,'venta por caja',9,1,NULL,0,'salePerBox'),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount'),(35,'cartera comprador',10,NULL,NULL,1,NULL),(36,'descuadre',12,NULL,NULL,1,'imbalance'),(37,'maná',7,4,NULL,0,'mana'),(38,'embolsado',9,NULL,NULL,1,'bagged'),(39,'maná auto',7,NULL,NULL,1,'autoMana'),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge'),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer'),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo'),(44,'rappel cadena',2,NULL,NULL,1,'rappel'); +INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0),(14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0),(15,'reparto',6,NULL,NULL,1,'delivery',1),(17,'recobro',5,NULL,NULL,1,'debtCollection',0),(21,'ajuste',11,NULL,NULL,1,'adjustment',0),(22,'venta por paquete',9,1,NULL,0,'salePerPackage',0),(23,'venta por caja',9,2,NULL,0,'salePerBox',0),(28,'valor de compra',1,NULL,NULL,1,'purchaseValue',1),(29,'margen',4,NULL,NULL,1,'margin',1),(32,'descuento ultimas unidades',9,3,-0.05,0,'lastUnitsDiscount',0),(33,'venta por caja',9,1,NULL,0,'salePerBox',0),(34,'descuento comprador',4,NULL,NULL,1,'buyerDiscount',0),(35,'cartera comprador',10,NULL,NULL,1,NULL,0),(36,'descuadre',12,NULL,NULL,1,'imbalance',0),(37,'maná',7,4,NULL,0,'mana',0),(38,'embolsado',9,NULL,NULL,1,'bagged',0),(39,'maná auto',7,NULL,NULL,1,'autoMana',0),(40,'cambios Santos 2016',4,NULL,NULL,1,NULL,0),(41,'bonificacion porte',6,NULL,NULL,1,'freightCharge',0),(42,'promocion Francia',4,NULL,NULL,1,'frenchOffer',0),(43,'promocion Floramondo',4,NULL,NULL,1,'floramondoPromo',0),(44,'rappel cadena',2,NULL,NULL,1,'rappel',0); /*!40000 ALTER TABLE `component` ENABLE KEYS */; UNLOCK TABLES; @@ -403,6 +403,16 @@ LOCK TABLES `continent` WRITE; INSERT INTO `continent` VALUES (1,'Asia','AS'),(2,'América','AM'),(3,'África','AF'),(4,'Europa','EU'),(5,'Oceanía','OC'); /*!40000 ALTER TABLE `continent` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `volumeConfig` +-- + +LOCK TABLES `volumeConfig` WRITE; +/*!40000 ALTER TABLE `volumeConfig` DISABLE KEYS */; +INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57); +/*!40000 ALTER TABLE `volumeConfig` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -412,9 +422,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:51 +-- Dump completed on 2021-05-25 11:53:09 USE `cache`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ @@ -448,9 +458,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:51 +-- Dump completed on 2021-05-25 11:53:10 USE `hedera`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ @@ -514,9 +524,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:51 +-- Dump completed on 2021-05-25 11:53:10 USE `postgresql`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ @@ -588,7 +598,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,1125,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2858,5,'Av constitución 3',554145),(6,'Vilassar',88,88032,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,NULL,60,'Fenollars, 20',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,1177,1,'Av espioca 100',552703),(2,'Mercaflor',19,NULL,NULL,NULL,NULL),(3,'Marjales',26,20008,NULL,NULL,NULL),(4,'VNH',NULL,NULL,3,NULL,NULL),(5,'Madrid',28,2861,5,'Av constitución 3',554145),(6,'Vilassar',88,88035,2,'Cami del Crist, 33',556412),(7,'Tenerife',NULL,NULL,10,NULL,NULL),(8,NULL,NULL,NULL,NULL,NULL,NULL),(9,'Algemesi',20,NULL,60,'Fenollars, 20',523549),(10,NULL,NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -600,9 +610,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:52 +-- Dump completed on 2021-05-25 11:53:10 USE `sage`; --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: sage -- ------------------------------------------------------ @@ -624,7 +634,7 @@ USE `sage`; LOCK TABLES `TiposIva` WRITE; /*!40000 ALTER TABLE `TiposIva` DISABLE KEYS */; -INSERT INTO `TiposIva` VALUES (2,0,'Operaciones no sujetas',0.0000000000,0.0000000000,0.0000000000,'','4770000020','','','','','','','95B21A93-5910-489D-83BB-C32788C9B19D','','','','','','','','','',0,0),(4,0,'I.V.A. 4%',0.0000000000,4.0000000000,0.0000000000,'4720000004','4770000004','','6310000000','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0,0),(5,0,'I.V.A. 4% y R.E. 0.5%',0.0000000000,4.0000000000,0.5000000000,'','4770000504','4770000405','','','','','','DBEFA562-63FB-4FFC-8171-64F0C6F065FF','','','','','','','','','',0,0),(6,0,'H.P. IVA 4% CEE',0.0000000000,4.0000000000,0.0000000000,'4721000004','4771008888','','','','','','','DD0ECBA8-2EF5-425E-911B-623580BADA77','','','','','','','','','',0,1),(7,0,'H.P. IVA 10% CEE',0.0000000000,10.0000000000,0.0000000000,'4721000011','4771008888','','','','','','','593208CD-6F28-4489-B6EC-907AD689EAC9','','','','','','','','','',0,1),(8,0,'H.P. IVA 21% CEE',0.0000000000,21.0000000000,0.0000000000,'4721000021','4771008888','','','','','','','27061852-9BC1-4C4F-9B6E-69970E208F23','','','','','','','','','',0,1),(10,0,'I.V.A. 10% Nacional',0.0000000000,10.0000000000,0.0000000000,'4720000011','4770000010','','','','','','','828A9D6F-5C01-4C3A-918A-B2E4482830D3','','','','','','','','','',0,0),(11,0,'I.V.A. 10% y R.E. 1,4%',0.0000000000,10.0000000000,1.4000000000,'','4770000101','4770000110','','','','','','C1F2D910-83A1-4191-A76C-8B3D7AB98348','','','','','','','','','',0,0),(16,0,'I.V.A. Adqui. servicios CEE',0.0000000000,21.0000000000,0.0000000000,'4721000015','4771000016','','','','','','','E3EDE961-CE8F-41D4-9E6C-D8BCD32275A1','','','','','','','','','',0,1),(18,0,'H.P. Iva Importación 0% ISP',0.0000000000,0.0000000000,0.0000000000,'4720000005','4770000005','','','','','','','27AD4158-2349-49C2-B53A-A4E0EFAC5D09','','','','','','','','','',0,0),(20,0,'I.V.A 0% Nacional',0.0000000000,0.0000000000,0.0000000000,'4720000000','','','','','','','','B90B0FBD-E513-4F04-9721-C873504E08DF','','','','','','','','','',0,0),(21,0,'I.V.A. 21%',0.0000000000,21.0000000000,0.0000000000,'4720000021','4770000021','4770000000','','','','','','BA8C4E28-DCFA-4F7B-AE4F-CA044626B55E','','','','','','','','','',0,0),(22,0,'IVA 10% importaciones',0.0000000000,10.0000000000,0.0000000000,'4722000010','','','','','','','','540450A8-4B41-4607-96D1-E7F296FB6933','','','','','','','','','',0,0),(26,0,'I.V.A. 21% y R.E. 5,2%',0.0000000000,21.0000000000,5.2000000000,'4720000021','4770000215','4770000521','631000000','','','','','2BC0765F-7739-49AE-A5F0-28B648B81677','','','','','','','','','',0,0),(90,0,'IVA 21% importaciones',0.0000000000,21.0000000000,0.0000000000,'4722000021','','','','','','','','EB675F91-5FF2-4E26-A31E-EEB674125945','','','','','','','','','',0,0),(91,0,'IVA 0% importaciones',0.0000000000,0.0000000000,0.0000000000,'4723000000','','','','','','','','5E5EFA56-2A99-4D54-A16B-5D818274CA18','','','','','','','','','',0,0),(93,0,'12% com. agrícola o forestal',0.0000000000,12.0000000000,0.0000000000,'4720000012','','','','','','','','267B1DDB-247F-4A71-AB95-3349FEFC5F92','','','','','','','','','',0,0),(110,0,'HP IVA Devengado Exento CEE',0.0000000000,0.0000000000,0.0000000000,'','4771000000','','','','','','','C605BC32-E161-42FD-83F3-3A66B1FBE399','','','','','','','','','',0,1),(111,0,'H.P. Iva Devengado Exento Ser',0.0000000000,0.0000000000,0.0000000000,'','4771000001','','','','','','','F1AEC4DC-AFE5-498E-A713-2648FFB6DA32','','','','','','','','','',0,0),(112,0,'H.P. IVA Devengado en exportac',0.0000000000,0.0000000000,0.0000000000,'','4770000002','','','','','','','F980AE74-BF75-4F4C-927F-0CCCE0DB8D15','','','','','','','','','',0,0),(113,0,'HP DEVENGADO 21 ISP ',0.0000000000,21.0000000000,0.0000000000,'4720000006','4770000006','','','','','','','728D7A76-E936-438C-AF05-3CA38FE16EA5','','','','','','','','','',0,0); +INSERT INTO `TiposIva` VALUES (2,0,'Operaciones no sujetas',0.0000000000,0.0000000000,0.0000000000,'','4770000020','','','','','','','95B21A93-5910-489D-83BB-C32788C9B19D','','','','','','','','','',0,0),(4,0,'I.V.A. 4%',0.0000000000,4.0000000000,0.0000000000,'4720000004','4770000004','','6310000000','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0,0),(5,0,'I.V.A. 4% y R.E. 0.5%',0.0000000000,4.0000000000,0.5000000000,'','4770000504','4770000405','','','','','','DBEFA562-63FB-4FFC-8171-64F0C6F065FF','','','','','','','','','',0,0),(6,0,'H.P. IVA 4% CEE',0.0000000000,4.0000000000,0.0000000000,'4721000004','4771000004','','','','','','','DD0ECBA8-2EF5-425E-911B-623580BADA77','','','','','','','','','',0,1),(7,0,'H.P. IVA 10% CEE',0.0000000000,10.0000000000,0.0000000000,'4721000011','4771000010','','','','','','','593208CD-6F28-4489-B6EC-907AD689EAC9','','','','','','','','','',0,1),(8,0,'H.P. IVA 21% CEE',0.0000000000,21.0000000000,0.0000000000,'4721000021','4771000021','','','','','','','27061852-9BC1-4C4F-9B6E-69970E208F23','','','','','','','','','',0,1),(10,0,'I.V.A. 10% Nacional',0.0000000000,10.0000000000,0.0000000000,'4720000011','4770000010','','6290000553','','','','','828A9D6F-5C01-4C3A-918A-B2E4482830D3','','','','','','','','','',0,0),(11,0,'I.V.A. 10% y R.E. 1,4%',0.0000000000,10.0000000000,1.4000000000,'','4770000101','4770000110','','','','','','C1F2D910-83A1-4191-A76C-8B3D7AB98348','','','','','','','','','',0,0),(16,0,'I.V.A. Adqui. servicios CEE',0.0000000000,21.0000000000,0.0000000000,'4721000015','4771000016','','','','','','','E3EDE961-CE8F-41D4-9E6C-D8BCD32275A1','','','','','','','','','',0,1),(18,0,'H.P. Iva Importación 0% ISP',0.0000000000,0.0000000000,0.0000000000,'4720000005','4770000005','','','','','','','27AD4158-2349-49C2-B53A-A4E0EFAC5D09','','','','','','','','','',0,0),(20,0,'I.V.A 0% Nacional',0.0000000000,0.0000000000,0.0000000000,'4720000000','','','','','','','','B90B0FBD-E513-4F04-9721-C873504E08DF','','','','','','','','','',0,0),(21,0,'I.V.A. 21%',0.0000000000,21.0000000000,0.0000000000,'4720000021','4770000021','4770000000','','','','','','BA8C4E28-DCFA-4F7B-AE4F-CA044626B55E','','','','','','','','','',0,0),(22,0,'IVA 10% importaciones',0.0000000000,10.0000000000,0.0000000000,'4722000010','','','','','','','','540450A8-4B41-4607-96D1-E7F296FB6933','','','','','','','','','',0,0),(26,0,'I.V.A. 21% y R.E. 5,2%',0.0000000000,21.0000000000,5.2000000000,'4720000021','4770000215','4770000521','631000000','','','','','2BC0765F-7739-49AE-A5F0-28B648B81677','','','','','','','','','',0,0),(90,0,'IVA 21% importaciones',0.0000000000,21.0000000000,0.0000000000,'4722000021','','','','','','','','EB675F91-5FF2-4E26-A31E-EEB674125945','','','','','','','','','',0,0),(91,0,'IVA 0% importaciones',0.0000000000,0.0000000000,0.0000000000,'4723000000','','','','','','','','5E5EFA56-2A99-4D54-A16B-5D818274CA18','','','','','','','','','',0,0),(92,0,'8.5% comp. ganadera o pesquera',0.0000000000,8.5000000000,0.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(93,0,'12% com. agrícola o forestal',0.0000000000,12.0000000000,0.0000000000,'4720000012','','','','','','','','267B1DDB-247F-4A71-AB95-3349FEFC5F92','','','','','','','','','',0,0),(94,0,'10,5% com. ganadera o pesquera',0.0000000000,10.5000000000,0.0000000000,'4770000000','4720000000','631000000','477000000','','','','','','','','','','','','','','',0,0),(108,0,'I.V.A. 8%',0.0000000000,8.0000000000,0.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(109,0,'I.V.A. 8% y R.E. 1%',0.0000000000,8.0000000000,1.0000000000,'4720000000','4770000000','477000000','631000000','','','','','','','','','','','','','','',0,0),(110,0,'HP IVA Devengado Exento CEE',0.0000000000,0.0000000000,0.0000000000,'','4771000000','','','','','','','C605BC32-E161-42FD-83F3-3A66B1FBE399','','','','','','','','','',0,1),(111,0,'H.P. Iva Devengado Exento Ser',0.0000000000,0.0000000000,0.0000000000,'','4771000001','','','','','','','F1AEC4DC-AFE5-498E-A713-2648FFB6DA32','','','','','','','','','',0,0),(112,0,'H.P. IVA Devengado en exportac',0.0000000000,0.0000000000,0.0000000000,'','4770000002','','','','','','','F980AE74-BF75-4F4C-927F-0CCCE0DB8D15','','','','','','','','','',0,0),(113,0,'HP DEVENGADO 21 ISP ',0.0000000000,21.0000000000,0.0000000000,'4720000006','4770000006','','','','','','','728D7A76-E936-438C-AF05-3CA38FE16EA5','','','','','','','','','',0,0),(114,0,'HP.IVA NO DEDUCIBLE 10%',0.0000000000,0.0000000000,0.0000000000,'4720000026','','','','','','','','','','','','','','','','','',0,0); /*!40000 ALTER TABLE `TiposIva` ENABLE KEYS */; UNLOCK TABLES; @@ -656,4 +666,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-03-30 11:16:52 +-- Dump completed on 2021-05-25 11:53:11 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f34386676..d0d215900 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -125,13 +125,13 @@ INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) (1, 'Main Warehouse'), (2, 'Silla'); -INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`) +INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasStowaway`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`) VALUES - (1, 'Warehouse One', 1, 1, 1, 1, 1, 1, 1, 2, 1), - (2, 'Warehouse Two', 1, 1, 1, 1, 0, 0, 1, 2, 13), - (3, 'Warehouse Three', 1, 1, 1, 1, 0, 0, 0, 2, 1), - (4, 'Warehouse Four', 1, 1, 1, 1, 0, 0, 0, 2, 1), - (5, 'Warehouse Five', 1, 1, 1, 1, 0, 0, 0, 2, 1); + (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 2, 1), + (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 0, 1, 2, 13), + (3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), + (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1), + (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 0, 2, 1); INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `pickingPlacement`, `path`) VALUES @@ -459,6 +459,19 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', NULL), (1381, 'ORN', NULL, 30, NULL, 7, NULL, 'ORN Company - Plant passport'); +INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) + VALUES + ('CEE', 1, 10), + ('EQU', 0, 1), + ('NATIONAL', 0, 1), + ('WORLD', 2, 15); + +INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`) + VALUES + ('A', 'Global nacional', 1, 'NATIONAL', 0), + ('T', 'Española rapida', 1, 'NATIONAL', 0), + ('V', 'Intracomunitaria global', 0, 'CEE', 1); + INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES (1, 'T', 1014.24, CURDATE(), 101, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1), @@ -504,19 +517,6 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (6, 4, 8.07, 2000000000, CURDATE()), (7, 5, 8.07, 2000000000, CURDATE()); -INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) - VALUES - ('CEE', 1, 10), - ('EQU', 0, 1), - ('NATIONAL', 0, 1), - ('WORLD', 2, 15); - -INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`) - VALUES - ('A', 'Global nacional', 1, 'NATIONAL', 0), - ('T', 'Española rapida', 1, 'NATIONAL', 0), - ('V', 'Intracomunitaria global', 0, 'CEE', 1); - INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `m3Max`) VALUES (1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 30.50), @@ -774,6 +774,12 @@ INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) (05080000, 'Coral y materiales similares', 2, 2), (06021010, 'Plantas vivas: Esqueje/injerto, Vid', 1, 1); +INSERT INTO `vn`.`itemFamily`(`code`, `description`) + VALUES + ('EMB', 'Packagings'), + ('SER', 'Services'), + ('VT', 'Sales'); + INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `isOnOffer`, `expenceFk`, `isBargain`, `comment`, `relevancy`, `image`, `taxClassFk`, `subName`, `minPrice`, `stars`, `family`) VALUES (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 0, 2000000000, 0, NULL, 0, '1', 1, NULL, 0, 1, 'VT'), @@ -2250,10 +2256,6 @@ INSERT INTO `vn`.`campaign`(`code`, `dated`) ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-11-01')), ('allSaints', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -3 YEAR)), '-11-01')); -INSERT INTO `hedera`.`image`(`collectionFk`, `name`) - VALUES - ('user', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd'); - INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height`) VALUES (1, 4, 160, 160); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 407770aef..8df46890d 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1,4 +1,4 @@ --- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -405,12 +405,12 @@ CREATE TABLE `user` ( `emailVerified` tinyint(1) DEFAULT NULL, `verificationToken` varchar(512) CHARACTER SET utf8 DEFAULT NULL, `lang` char(2) CHARACTER SET utf8 DEFAULT NULL, - `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT '1', `lastPassChange` datetime DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `password` char(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', `image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `password` char(64) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Deprecated', + `recoverPass` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT 'Deprecated', `sync` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Deprecated', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), @@ -448,15 +448,19 @@ 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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `user_afterInsert` - AFTER INSERT ON `user` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER user_afterInsert + AFTER INSERT + ON user + FOR EACH ROW BEGIN + CALL hedera.image_ref('user', NEW.image); + INSERT IGNORE INTO userSync SET `name` = NEW.`name`; END */;; DELIMITER ; @@ -497,17 +501,24 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `user_afterUpdate` - AFTER UPDATE ON `user` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER user_afterUpdate + AFTER UPDATE + ON user + FOR EACH ROW BEGIN + IF !(NEW.image <=> OLD.image) THEN + CALL hedera.image_unref('user', OLD.image); + CALL hedera.image_ref('user', NEW.image); + END IF; + INSERT IGNORE INTO userSync SET `name` = NEW.`name`; IF !(OLD.`name` <=> NEW.`name`) THEN INSERT IGNORE INTO userSync SET `name` = OLD.`name`; END IF; - + IF !(NEW.`role` <=> OLD.`role`) THEN INSERT INTO vn.mail SET @@ -526,15 +537,19 @@ 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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `user_afterDelete` - AFTER DELETE ON `user` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER user_afterDelete + AFTER DELETE + ON user + FOR EACH ROW BEGIN + CALL hedera.image_unref('user', OLD.image); + INSERT IGNORE INTO userSync SET `name` = OLD.`name`; END */;; DELIMITER ; @@ -1276,8 +1291,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `myUser_changePassword`(vOldPassword VARCHAR(255), vPassword VARCHAR(255)) BEGIN /** - * Changes the current user password, if user is in recovery mode ignores the - * current password. + * Changes the current user password. * * @param vOldPassword The current password * @param vPassword The new password @@ -1422,6 +1436,31 @@ 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 `myUser_restorePassword` */; +/*!50003 SET @saved_cs_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 `myUser_restorePassword`(vVerificationToken VARCHAR(255), vPassword VARCHAR(255)) +BEGIN +/** + * Changes the current user password using recovery token. + * + * @param vVerificationToken The current password + * @param vPassword The new password + */ + CALL user_restorePassword(myUser_getId(), vVerificationToken, vPassword); +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 `role_checkName` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2338,6 +2377,44 @@ 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 `user_restorePassword` */; +/*!50003 SET @saved_cs_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 `user_restorePassword`(vSelf INT, vVerificationToken VARCHAR(255), vPassword VARCHAR(255)) +BEGIN +/** + * Changes the user password using recovery token. + * + * @param vSelf The user id + * @param vVerificationToken The verification token + * @param vPassword The new password + */ + DECLARE vTokenVerified BOOL; + DECLARE vUserName VARCHAR(255); + + SELECT verificationToken = vVerificationToken, `name` + INTO vTokenVerified, vUserName + FROM user WHERE id = vSelf; + + IF NOT vTokenVerified THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Invalid verification token'; + END IF; + + CALL user_setPassword(vSelf, vPassword); +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 `user_setPassword` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2362,7 +2439,7 @@ BEGIN UPDATE user SET `password` = MD5(vPassword), - `recoverPass` = FALSE + `verificationToken` = NULL WHERE id = vSelf; END ;; DELIMITER ; @@ -2672,6 +2749,28 @@ CREATE TABLE `indicators` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores actuales para una consulta diaria rápida por los directivos.'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `inspeccionSS_2021` +-- + +DROP TABLE IF EXISTS `inspeccionSS_2021`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `inspeccionSS_2021` ( + `business_id` int(11) DEFAULT NULL, + `id` int(11) NOT NULL DEFAULT '0', + `firstName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `lastName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `timed` datetime NOT NULL, + `hours_week` smallint(6) DEFAULT NULL, + `year` int(4) NOT NULL, + `week` int(2) NOT NULL, + `dated` date NOT NULL, + `orden` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='bs.inspeccionSS_2021_add()'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `lastIndicators` -- @@ -2968,6 +3067,23 @@ CREATE TABLE `nightTaskConfig` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `packingSpeed` +-- + +DROP TABLE IF EXISTS `packingSpeed`; +/*!50001 DROP VIEW IF EXISTS `packingSpeed`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `packingSpeed` ( + `hora` tinyint NOT NULL, + `minuto` tinyint NOT NULL, + `cm3` tinyint NOT NULL, + `warehouse_id` tinyint NOT NULL, + `odbc_date` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `payMethodClient` -- @@ -3296,10 +3412,15 @@ CREATE TABLE `waste` ( `year` int(4) NOT NULL, `week` int(2) NOT NULL, `family` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `itemFk` int(11) DEFAULT NULL, + `itemTypeFk` smallint(5) unsigned DEFAULT NULL, `saleTotal` decimal(16,0) DEFAULT NULL, `saleWaste` decimal(16,0) DEFAULT NULL, - `rate` decimal(3,1) DEFAULT NULL, - PRIMARY KEY (`buyer`,`year`,`week`,`family`) + `rate` decimal(5,1) DEFAULT NULL, + KEY `waste_itemType_id` (`itemTypeFk`), + KEY `waste_item_id` (`itemFk`), + CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3375,6 +3496,38 @@ CREATE TABLE `workerSpeed__` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `zone_ETD` +-- + +DROP TABLE IF EXISTS `zone_ETD`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zone_ETD` ( + `zoneFk` int(11) DEFAULT NULL, + `totalVolume` decimal(5,1) DEFAULT NULL, + `remainingVolume` decimal(5,1) DEFAULT NULL, + `speed` decimal(10,2) NOT NULL DEFAULT '0.00', + `hourTheoretical` time DEFAULT NULL, + `hourPractical` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `zone_ETD_byTime` +-- + +DROP TABLE IF EXISTS `zone_ETD_byTime`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zone_ETD_byTime` ( + `theorical` time NOT NULL, + `practical` time NOT NULL DEFAULT '00:00:00', + `m3` decimal(10,1) NOT NULL DEFAULT '0.0', + PRIMARY KEY (`theorical`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Dumping events for database 'bs' -- @@ -3397,6 +3550,24 @@ DELIMITER ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `zone_ETD_byTime_Refresh` */;; +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 @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `zone_ETD_byTime_Refresh` ON SCHEDULE EVERY 5 MINUTE STARTS '2021-04-12 14:28:27' ON COMPLETION NOT PRESERVE ENABLE DO CALL bs.zone_ETD_byTime() */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; DELIMITER ; /*!50106 SET TIME_ZONE= @save_time_zone */ ; @@ -3816,9 +3987,9 @@ ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -3835,6 +4006,12 @@ BEGIN DELETE FROM ventas WHERE fecha < vFourYearsAgo; + + DELETE FROM payMethodClient + WHERE dated < vOneYearAgo; + + DELETE FROM payMethodClientEvolution + WHERE dated < vFourYearsAgo; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4744,6 +4921,60 @@ BEGIN END WHILE; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `inspeccionSS_2021_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 `inspeccionSS_2021_add`() +BEGIN + + TRUNCATE bs.inspeccionSS_2021; + + INSERT INTO bs.inspeccionSS_2021 + SELECT wbd.business_id , + w.id, + w.firstName, + w.lastName, + d.name , + wtc.timed , + cl.hours_week , + t.`year` , + t.week , + t.dated , + 0 AS orden + FROM vn.workerTimeControl wtc + JOIN vn.worker w ON w.id = wtc.userFk + JOIN vn.workerBusinessDated wbd ON wbd.workerFk = wtc.userFk AND wbd.dated = date(wtc.timed) + JOIN vn.time t ON t.dated = wbd.dated + JOIN postgresql.business_labour bl ON bl.business_id = wbd.business_id + JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id + JOIN vn.department d ON d.id = bl.department_id + JOIN vn.department d2 ON d2.id = d.parentFk AND d2.name = 'PRODUCCION' + WHERE wtc.timed BETWEEN '2020-10-01' AND '2021-04-19' + AND d.lft BETWEEN d2.lft AND d2.rgt + AND lastName NOT LIKE 'FERRER%'; + + SET @orden := 1; + SET @id := 0; + SET @day := 0; + + UPDATE bs.inspeccionSS_2021 + SET orden = IF(id = @id AND day(timed) = @day, @orden := @orden + 1, @orden := 1), + id = @id := id + (0 * @day := day(timed)) + ORDER BY id, timed; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5334,18 +5565,14 @@ 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 = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `saleGraphic`(vItemFk INT, - vTypeFk INT, - vCategoryFk INT, - vFromDate DATE, - vToDate DATE, - vProducerFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `saleGraphic`(IN vItemFk INT, IN vTypeFk INT, IN vCategoryFk INT, IN vFromDate DATE, + IN vToDate DATE, IN vProducerFk INT) BEGIN DECLARE vFromDateLastYear DATE; @@ -6560,7 +6787,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 `waste_Add` */; +/*!50003 DROP PROCEDURE IF EXISTS `waste_addSales` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -6570,117 +6797,85 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `waste_Add`() +CREATE DEFINER=`root`@`%` PROCEDURE `waste_addSales`() BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year + DECLARE vYear INT; + + SELECT week, year INTO vWeek, vYear - FROM vn.time - WHERE dated = CURDATE(); + FROM vn.time + WHERE dated = CURDATE(); - REPLACE bs.waste + REPLACE bs.waste SELECT *, 100 * mermas / total as porcentaje FROM ( SELECT buyer, year, - week, + week, family, + itemFk, + itemTypeFk, floor(sum(value)) as total, floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas FROM vn.saleValue where year = vYear and week = vWeek - GROUP BY family + GROUP BY family, itemFk ) sub ORDER BY mermas DESC; - 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 `weekWaste` */; +/*!50003 DROP PROCEDURE IF EXISTS `waste_addSales_lastWeek` */; /*!50003 SET @saved_cs_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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste`() +CREATE DEFINER=`root`@`%` PROCEDURE `waste_addSales_lastWeek`() BEGIN DECLARE vWeek INT; - DECLARE vYear INT; + DECLARE vYear INT; - SELECT week, year + SELECT week, year INTO vWeek, vYear - FROM vn.time - WHERE dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - sum(saleTotal) as total, - sum(saleWaste) as dwindle - FROM bs.waste - WHERE year = vYear and week = vWeek - GROUP BY buyer - ) sub - ORDER BY percentage DESC; -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 `weekWaste_byWorker` */; -/*!50003 SET @saved_cs_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 `weekWaste_byWorker`(vWorkerFk INT) -BEGIN - - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = TIMESTAMPADD(WEEK,-1,CURDATE()); - + FROM vn.time + WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE()); + + REPLACE bs.waste SELECT *, 100 * mermas / total as porcentaje FROM ( - SELECT ws.family, - sum(ws.saleTotal) as total, - sum(ws.saleWaste) as mermas - FROM bs.waste ws - JOIN vn.worker w ON w.user = ws.buyer - WHERE year = vYear AND week = vWeek - AND w.id = vWorkerFk - GROUP BY family + SELECT buyer, + year, + week, + family, + itemFk, + itemTypeFk, + floor(sum(value)) as total, + floor(sum(IF(clientTypeFk = 'loses', value, 0))) as mermas + FROM vn.saleValue + where year = vYear and week = vWeek + + GROUP BY family, itemFk ) sub - ORDER BY porcentaje DESC; + ORDER BY mermas DESC; 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 `weekWaste_getDetail` */; +/*!50003 DROP PROCEDURE IF EXISTS `weekWaste_byWorker__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -6690,27 +6885,105 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_getDetail`() +CREATE DEFINER=`root`@`%` PROCEDURE `weekWaste_byWorker__`(IN vWorkerFk INT) BEGIN - DECLARE vLastWeek DATE; - DECLARE vWeek INT; + + DECLARE vWeek INT; DECLARE vYear INT; - - SET vLastWeek = TIMESTAMPADD(WEEK,-1,CURDATE()); + + SELECT week, year + INTO vWeek, vYear + FROM vn.time + WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE()); + + SELECT *, 100 * mermas / total AS porcentaje + FROM ( + SELECT ws.family, + SUM(ws.saleTotal) AS total, + SUM(ws.saleWaste) AS mermas + FROM bs.waste ws + JOIN vn.worker w ON w.user = ws.buyer + WHERE year = vYear + AND week = vWeek + AND w.id = vWorkerFk + GROUP BY family + ) sub + ORDER BY porcentaje DESC; +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 `weekWaste_getDetail__` */; +/*!50003 SET @saved_cs_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 `weekWaste_getDetail__`() +BEGIN + DECLARE vLastWeek DATE; + DECLARE vWeek INT; + DECLARE vYear INT; + + SET vLastWeek = TIMESTAMPADD(WEEK, -1, CURDATE()); SET vYear = YEAR(vLastWeek); SET vWeek = WEEK(vLastWeek, 1); - - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = vYear AND week = vWeek - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC; + + SELECT *, 100 * dwindle / total AS percentage + FROM ( + SELECT buyer, + ws.family, + SUM(ws.saleTotal) AS total, + SUM(ws.saleWaste) AS dwindle + FROM bs.waste ws + WHERE year = vYear + AND week = vWeek + GROUP BY buyer, family + ) sub + ORDER BY percentage DESC; +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 `weekWaste__` */; +/*!50003 SET @saved_cs_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 `weekWaste__`() +BEGIN + DECLARE vWeek INT; + DECLARE vYear INT; + + SELECT week, year + INTO vWeek, vYear + FROM vn.time + WHERE dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK); + + SELECT *, 100 * dwindle / total AS percentage + FROM ( + SELECT buyer, + SUM(saleTotal) AS total, + SUM(saleWaste) AS dwindle + FROM bs.waste + WHERE year = vYear + AND week = vWeek + GROUP BY buyer + ) sub + ORDER BY percentage DESC; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6963,6 +7236,53 @@ BEGIN SELECT * FROM bs.workerSpeed; +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 `zone_ETD_byTime` */; +/*!50003 SET @saved_cs_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 `zone_ETD_byTime`() +BEGIN + + SET @m := 0; + + SELECT MAX(hourTheoretical) INTO @h + FROM vn.zoneEstimatedDelivery ze + WHERE ze.remainingVolume ; + + DROP TEMPORARY TABLE IF EXISTS tmpZone; + + CREATE TEMPORARY TABLE tmpZone + SELECT remainingVolume, + hourTheoretical, + @m := @m + minutesLess + HOUR(TIMEDIFF(@h, hourTheoretical)) * 60 + MINUTE(TIMEDIFF(@h, hourTheoretical)) totalMinutes, + @h := hourTheoretical + FROM vn.zoneEstimatedDelivery ze + WHERE ze.remainingVolume + ORDER BY ze.hourTheoretical DESC; + + TRUNCATE bs.zone_ETD_byTime ; + + INSERT INTO bs.zone_ETD_byTime(theorical, practical, m3) + SELECT tz.hourTheoretical, + TIMESTAMPADD(MINUTE, MIN(totalMinutes), tz.hourTheoretical), + sum(tz.remainingVolume) + FROM tmpZone tz + GROUP BY tz.hourTheoretical; + + DROP TEMPORARY TABLE tmpZone; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7114,6 +7434,24 @@ CREATE TABLE `last_buy` ( UNIQUE KEY `item_id` (`item_id`,`warehouse_id`) USING HASH, KEY `buy_id` (`buy_id`), KEY `warehouse_id` (`warehouse_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `last_buy__` +-- + +DROP TABLE IF EXISTS `last_buy__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `last_buy__` ( + `item_id` int(10) unsigned NOT NULL, + `warehouse_id` smallint(5) unsigned NOT NULL, + `buy_id` int(10) unsigned DEFAULT NULL, + `landing` date DEFAULT NULL, + UNIQUE KEY `item_id` (`item_id`,`warehouse_id`) USING HASH, + KEY `buy_id` (`buy_id`), + KEY `warehouse_id` (`warehouse_id`) USING BTREE ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -7659,9 +7997,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_unicode_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 ;; @@ -7675,7 +8013,7 @@ BEGIN UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id SET cc.last_refresh = NOW(), - cc.expires = ADDTIME(NOW(), c.lifetime), + cc.expires = LEAST(ADDTIME(NOW(), c.lifetime), util.midNight()), cc.connection_id = NULL WHERE cc.id = v_calc; @@ -7879,9 +8217,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 ;; @@ -7902,10 +8240,10 @@ DECLARE vLoadingDelay DECIMAL(5) DEFAULT 2; DECLARE rs CURSOR FOR SELECT Departure - , Sum(pb.m3)/(GREATEST(IFNULL(v.m3,0),IFNULL(dp.minSpeed,0))) AS Horas - , curDate()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(v.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion + , Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(dp.minSpeed,0))) AS Horas + , curDate()+(Departure + vLoadingDelay -(Sum(pb.m3)/(GREATEST(IFNULL(lhp.m3,0),IFNULL(minSpeed,0))))/24) AS InicioPreparacion FROM tmp.production_buffer pb - LEFT JOIN vn2008.v_encajado_ultima_hora v ON v.warehouse_id = pb.warehouse_id + LEFT JOIN vn.lastHourProduction lhp ON lhp.warehouseFk = pb.warehouse_id LEFT JOIN cache.departure_limit dp ON dp.warehouse_id = pb.warehouse_id AND dp.fecha = CURDATE() WHERE pb.Fecha = CURDATE() AND pb.graphCategory > 1 @@ -8614,6 +8952,7 @@ CREATE TABLE `deliveryInformation` ( `supplyResponseID` int(11) DEFAULT NULL, `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), + UNIQUE KEY `deliveryInformation_UN` (`Location`,`LatestDeliveryDateTime`,`FirstOrderDateTime`,`LatestOrderDateTime`,`supplyResponseID`), KEY `fgbSupplyResponse_idx` (`supplyResponseID`), KEY `fgbSupplyResponse_idx2` (`FirstOrderDateTime`), KEY `fgbSupplyResponse_idx3` (`LatestOrderDateTime`) USING BTREE, @@ -8622,6 +8961,25 @@ CREATE TABLE `deliveryInformation` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `di` +-- + +DROP TABLE IF EXISTS `di`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `di` ( + `ID` int(11) NOT NULL DEFAULT '0', + `Location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `LatestDeliveryDateTime` datetime DEFAULT NULL, + `FirstOrderDateTime` datetime DEFAULT NULL, + `LatestOrderDateTime` datetime DEFAULT NULL, + `supplyResponseID` int(11) DEFAULT NULL, + PRIMARY KEY (`ID`), + UNIQUE KEY `di_UN` (`Location`,`LatestDeliveryDateTime`,`FirstOrderDateTime`,`LatestOrderDateTime`,`supplyResponseID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ekt` -- @@ -8700,6 +9058,28 @@ CREATE TABLE `ektEntryAssign__` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='define las condiciones para asignar entradas a los ekt'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `errorList` +-- + +DROP TABLE IF EXISTS `errorList`; +/*!50001 DROP VIEW IF EXISTS `errorList`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `errorList` ( + `id` tinyint NOT NULL, + `name` tinyint NOT NULL, + `longName` tinyint NOT NULL, + `quantity` tinyint NOT NULL, + `stock` tinyint NOT NULL, + `error` tinyint NOT NULL, + `deliveryInformationID` tinyint NOT NULL, + `supplyResponseID` tinyint NOT NULL, + `OrderTradeLineDateTime` tinyint NOT NULL, + `EndUserPartyGLN` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `exchange` -- @@ -9149,6 +9529,7 @@ CREATE TABLE `putOrder` ( `isOrderProcessed` tinyint(4) DEFAULT NULL, `error` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `barcode` varchar(25) COLLATE utf8_unicode_ci DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `orderTradelineItemID_UNIQUE` (`orderTradelineItemID`), KEY `deliveryInformationID_idx` (`deliveryInformationID`), @@ -9257,11 +9638,16 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() - AND i.supplyResponseFk = NEW.supplyResponseID; + AND i.supplyResponseFk = NEW.supplyResponseID + LIMIT 1; UPDATE vn.sale s + JOIN vn.ticket t ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN deliveryInformation di ON di.ID = NEW.deliveryInformationID SET s.quantity = 0 - WHERE s.id = vSaleFk; + WHERE t.clientFk = NEW.EndUserPartyGLN AND t.shipped >= CURDATE() + AND i.supplyResponseFk = NEW.supplyResponseID; INSERT INTO vn.mail (sender, `subject`, body) SELECT IF(u.id IS NOT NULL AND c.email IS NOT NULL, @@ -9277,7 +9663,7 @@ BEGIN FROM vn.sale s JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.`client` c ON c.id = t.clientFk - LEFT JOIN account.user u ON u.id= c.salesPersonFk AND u.name IN ('ruben', 'ismael') + LEFT JOIN account.user u ON u.id= c.salesPersonFk AND u.name IN ('ruben', 'ismaelalcolea') WHERE s.id = vSaleFk; END IF; @@ -9433,6 +9819,32 @@ CREATE TABLE `supplyResponse` ( /*!50003 SET @saved_cs_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 supplyResponse_BU +BEFORE UPDATE +ON supplyResponse FOR EACH ROW +BEGIN + + + INSERT INTO edi.supplyResponseLog (supplyResponseFk, NumberOfUnitsOld, NumberOfUnitsNew, lastVMPUpdate) + SELECT OLD.ID, OLD.NumberOfUnits, NEW.NumberOfUnits, v.dateTimeLastSync + FROM edi.VMPSettings v + WHERE v.VMPID = OLD.vmpID; + +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 */ ; @@ -9458,6 +9870,26 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `supplyResponseLog` +-- + +DROP TABLE IF EXISTS `supplyResponseLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `supplyResponseLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `supplyResponseFk` int(11) NOT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `NumberOfUnitsOld` int(11) DEFAULT NULL, + `NumberOfUnitsNew` int(11) DEFAULT NULL, + `lastVMPUpdate` datetime DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `supplyResponseLog_FK` (`supplyResponseFk`), + CONSTRAINT `supplyResponseLog_FK` FOREIGN KEY (`supplyResponseFk`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `type` -- @@ -9598,6 +10030,45 @@ BEGIN FROM supplyResponse sr LEFT JOIN edi.deliveryInformation di ON sr.ID = di.supplyResponseID WHERE di.LatestOrderDateTime < vOneWeekAgo OR di.ID IS 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 DROP PROCEDURE IF EXISTS `deliveryInformation_Delete` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = 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 `deliveryInformation_Delete`() +BEGIN + + DECLARE vID INT; + DECLARE vGap INT DEFAULT 100; + DECLARE vTope INT; + + SELECT MIN(ID), MAX(ID) + INTO vID, vTope + FROM edi.deliveryInformation; + + WHILE vID <= vTope DO + + SET vID = vID + vGap; + + DELETE + FROM edi.deliveryInformation + WHERE ID < vID + AND EarliestDespatchDateTime IS NULL; + + END WHILE; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9702,28 +10173,43 @@ BEGIN DECLARE vIsLot BOOLEAN; DECLARE vForceToPacking INT DEFAULT 2; DECLARE vEntryFk INT; + DECLARE vHasToChangePackagingFk BOOLEAN; -- Carga los datos necesarios del EKT - SELECT ref, qty, package, putOrderFk INTO vRef, vQty, vPackage, vPutOrderFk + SELECT ref, qty, package, putOrderFk, i2.id INTO vRef, vQty, vPackage, vPutOrderFk, vItem FROM ekt e LEFT JOIN item i ON e.ref = i.id - WHERE e.id = vSelf; + LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk + LEFT JOIN vn.item i2 ON i2.supplyResponseFk = po.supplyResponseID + WHERE e.id = vSelf + LIMIT 1; -- Asigna la entrada SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk; -- Inserta el cubo si no existe - IF vPackage = 800 - THEN - SET vPackage = 800 + vQty; + IF vPackage = 800 THEN + + SET vHasToChangePackagingFk = TRUE; + + IF vItem THEN + + SELECT vn.item_getPackage(vItem) INTO vPackage ; + + ELSE + + SET vPackage = 8000 + vQty; - INSERT IGNORE INTO vn2008.Cubos SET - Id_Cubo = vPackage, - x = 7200 / vQty, - y = 1; + INSERT IGNORE INTO vn.packaging(id, width, `depth`) + SELECT vPackage, vc.ccLength / vQty, vc.ccWidth + FROM vn.volumeConfig vc; + + END IF; + ELSE + INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) FROM bucket WHERE bucket_id = vPackage; @@ -9745,6 +10231,7 @@ BEGIN JOIN vn.item i ON i.supplyResponseFk = po.supplyResponseID WHERE po.id = vPutOrderFk LIMIT 1; + END IF; INSERT IGNORE INTO item_track SET @@ -9808,14 +10295,13 @@ BEGIN ,@pac * e.qty ,vForceToPacking ,s.`name` - ,IFNULL(b.packageFk, e.package) + ,IF(vHasToChangePackagingFk OR ISNULL(b.packageFk), vPackage, b.packageFk) ,i.density * (vn.item_getVolume(i.id, IFNULL(b.packageFk, e.package)) / 1000000) FROM edi.ekt e LEFT JOIN vn.buy b ON b.id = vBuy LEFT JOIN vn.item i ON i.id = b.itemFk LEFT JOIN vn.supplier s ON e.pro = s.id - JOIN vn2008.config cfg - + JOIN vn2008.config cfg WHERE e.id = vSelf LIMIT 1; @@ -9827,6 +10313,177 @@ BEGIN WHERE ektFk = vSelf; CALL vn.buy_recalcPrices(); + +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 `ekt_load_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 `ekt_load_beta`(IN `vSelf` INT) +BEGIN + DECLARE vRef INT; + DECLARE vBuy INT; + DECLARE vItem INT; + DECLARE vQty INT; + DECLARE vPackage INT; + DECLARE vPutOrderFk INT; + DECLARE vIsLot BOOLEAN; + DECLARE vForceToPacking INT DEFAULT 2; + DECLARE vEntryFk INT; + DECLARE vHasToChangePackagingFk BOOLEAN; + + -- Carga los datos necesarios del EKT + + SELECT ref, qty, package, putOrderFk, i2.id INTO vRef, vQty, vPackage, vPutOrderFk, vItem + FROM ekt e + LEFT JOIN item i ON e.ref = i.id + LEFT JOIN edi.putOrder po ON po.id = e.putOrderFk + LEFT JOIN vn.item i2 ON i2.supplyResponseFk = po.supplyResponseID + WHERE e.id = vSelf + LIMIT 1; + + SELECT vItem; + + -- Asigna la entrada + SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk; + + -- Inserta el cubo si no existe + + IF vPackage = 800 THEN + + SET vHasToChangePackagingFk = TRUE; + + IF vItem THEN + + SELECT vn.item_getPackage(vItem) INTO vPackage ; + + ELSE + + SET vPackage = 8000 + vQty; + + INSERT IGNORE INTO vn.packaging(id, width, `depth`) + SELECT vPackage, vc.ccLength / vQty, vc.ccWidth + FROM vn.volumeConfig vc; + + END IF; + + ELSE + + INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) + SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) + FROM bucket WHERE bucket_id = vPackage; + + IF ROW_COUNT() > 0 + THEN + INSERT INTO vn2008.mail SET + `subject` = 'Cubo añadido', + `text` = CONCAT('Se ha añadido el cubo: ', vPackage), + `to` = 'ekt@verdnatura.es'; + END IF; + END IF; + + -- Si es una compra de Floramondo obtiene el articulo + IF vPutOrderFk THEN + + SELECT i.id INTO vItem + FROM edi.putOrder po + JOIN vn.item i ON i.supplyResponseFk = po.supplyResponseID + WHERE po.id = vPutOrderFk + LIMIT 1; + + END IF; + + INSERT IGNORE INTO item_track SET + item_id = vRef; + + IF IFNULL(vItem,0) = 0 THEN + -- Intenta obtener el artículo en base a los atributos holandeses + + SELECT b.id, b.itemFk INTO vBuy, vItem + FROM edi.ekt e + JOIN edi.item_track t ON t.item_id = e.ref + LEFT JOIN edi.ekt l ON l.ref = e.ref + LEFT JOIN vn.buy b ON b.ektFk = l.id + JOIN vn2008.config cfg + WHERE e.id = vSelf + AND l.id != vSelf + AND b.itemFk != cfg.generic_item + AND IF(t.s1, l.s1 = e.s1, TRUE) + AND IF(t.s2, l.s2 = e.s2, TRUE) + AND IF(t.s3, l.s3 = e.s3, TRUE) + AND IF(t.s4, l.s4 = e.s4, TRUE) + AND IF(t.s5, l.s5 = e.s5, TRUE) + AND IF(t.s6, l.s6 = e.s6, TRUE) + AND IF(t.kop, l.kop = e.kop, TRUE) + AND IF(t.pac, l.pac = e.pac, TRUE) + AND IF(t.cat, l.cat = e.cat, TRUE) + AND IF(t.ori, l.ori = e.ori, TRUE) + AND IF(t.pro, l.pro = e.pro, TRUE) + AND IF(t.sub, l.sub = e.sub, TRUE) + AND IF(t.package, l.package = e.package, TRUE) + AND IF(t.item, l.item = e.item, TRUE) + AND b.itemFk < 170000 + ORDER BY l.now DESC, b.id ASC LIMIT 1; + + END IF; + + + INSERT INTO vn.buy + ( + entryFk + ,ektFk + ,buyingValue + ,itemFk + ,stickers + ,packing + ,`grouping` + ,quantity + ,groupingMode + ,producer + ,packageFk + ,weight + ) + SELECT + vEntryFk + ,vSelf + ,(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue + ,IFNULL(vItem, cfg.generic_item) itemFk + ,e.qty stickers + ,@pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing + ,IFNULL(b.`grouping`, e.pac) + ,@pac * e.qty + ,vForceToPacking + ,s.`name` + ,IF(vHasToChangePackagingFk OR ISNULL(b.packageFk), vPackage, b.packageFk) + ,i.density * (vn.item_getVolume(i.id, IFNULL(b.packageFk, e.package)) / 1000000) + FROM edi.ekt e + LEFT JOIN vn.buy b ON b.id = vBuy + LEFT JOIN vn.item i ON i.id = b.itemFk + LEFT JOIN vn.supplier s ON e.pro = s.id + JOIN vn2008.config cfg + WHERE e.id = vSelf + LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; + + CREATE TEMPORARY TABLE tmp.buyRecalc + SELECT buy.id + FROM vn.buy + WHERE ektFk = vSelf; + + CALL vn.buy_recalcPrices(); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -10049,7 +10706,7 @@ proc: BEGIN DECLARE vSupplyResponseFk INT; DECLARE vLastInserted DATETIME; DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 100000; + DECLARE vMaxNewItems INT DEFAULT 10000; DECLARE vStartingTime DATETIME; DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; @@ -10098,10 +10755,12 @@ proc: BEGIN ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode - GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference + GROUP BY t.srId + -- GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference ; - -- -- select now(),'Antes de crear edi.offer'; + -- select now(),'Antes de crear edi.offer'; + DROP TEMPORARY TABLE IF EXISTS edi.offer; CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`)) ENGINE = MEMORY SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value, @@ -10148,15 +10807,19 @@ proc: BEGIN AND i.EmbalageCode <=> o.EmbalageCode AND i.quality <=> o.Quality JOIN vn.itemType it ON it.id = i.typeFk + LEFT JOIN vn.sale s ON s.itemFk = i.id + LEFT JOIN vn.ticket t ON t.id = s.ticketFk AND t.shipped > TIMESTAMPADD(WEEK, -1, CURDATE()) LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN deliveryInformation di ON di.supplyResponseID = sr.ID + LEFT JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID + LEFT JOIN edi.putOrder po ON po.supplyResponseID = i.supplyResponseFk AND po.OrderTradeLineDateTime > TIMESTAMPADD(WEEK, -1, CURDATE()) SET i.supplyResponseFk = o.srID WHERE ( sr.ID IS NULL OR sr.NumberOfUnits = 0 OR di.LatestOrderDateTime < NOW() OR di.ID IS NULL) AND it.isInventory - ; + AND t.id IS NULL + AND po.id IS NULL; -- select now(),'Antes de crear ITO'; DROP TEMPORARY TABLE IF EXISTS itemToInsert; CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY @@ -10201,21 +10864,24 @@ proc: BEGIN numberOfItemsPerCask, embalageCode, quality, - isFloramondo) - SELECT itemFk, - product_name, - product_name, - company_name, - expenseFk, - itemTypeFk, - intrastatFk, - originFk, - `srId`, - NumberOfItemsPerCask, - EmbalageCode, - Quality, - TRUE - FROM itemToInsert; + isFloramondo, + inkFk) + SELECT iti.itemFk, + iti.product_name, + iti.product_name, + iti.company_name, + iti.expenseFk, + iti.itemTypeFk, + iti.intrastatFk, + iti.originFk, + iti.`srId`, + iti.NumberOfItemsPerCask, + iti.EmbalageCode, + iti.Quality, + TRUE, + ii.inkFk + FROM itemToInsert iti + LEFT JOIN vn.itemInk ii ON ii.longName = iti.product_name; INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) SELECT i.id, PictureReference @@ -10442,430 +11108,6 @@ proc: BEGIN INSERT INTO edi.log(tableName, fieldName,fieldValue) VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); -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 `floramondo_offerRefresh_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 `floramondo_offerRefresh_beta`() -proc: BEGIN - - DECLARE vLanded DATETIME; - DECLARE done INT DEFAULT FALSE; - DECLARE vFreeId INT; - DECLARE vSupplyResponseFk INT; - DECLARE vLastInserted DATETIME; - DECLARE vIsAuctionDay BOOLEAN; - DECLARE vMaxNewItems INT DEFAULT 100000; - DECLARE vStartingTime DATETIME; - DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043'; - DECLARE vLastUpdated DATETIME DEFAULT now(); - - DECLARE cur1 CURSOR FOR - SELECT id - FROM edi.item_free; - - DECLARE cur2 CURSOR FOR - SELECT srId - FROM itemToInsert; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SET vStartingTime = NOW(); - - -- CALL vn.clean_logiflora(); - - -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg) - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority) - SELECT i.id, sr.PictureReference , 100 - FROM edi.supplyResponse sr - JOIN vn.item i ON i.supplyResponseFk = sr.ID - WHERE i.image != edi.imageName(sr.PictureReference) - AND sr.NumberOfUnits > 0; - - -- Elimina de la lista de items libres aquellos que ya existen - DELETE itf.* - FROM edi.item_free itf - JOIN vn.item i ON i.id = itf.id; - - DROP TEMPORARY TABLE IF EXISTS tmp; - CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY - SELECT t.*, - IFNULL(idt.itemTypeFk, igo.itemTypeFk) itemTypeFk, - igo.expenseFk , - igo.intrastatFk , - igo.originFk - FROM ( - SELECT * - FROM edi.supplyOffer so - JOIN vn.floramondoConfig fc - WHERE so.supplyResponseUpdated > fc.LastUpdated - ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t - JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id - LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode - GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price, PictureReference - ; - - -- -- select now(),'Antes de crear edi.offer'; - DROP TEMPORARY TABLE IF EXISTS edi.offer; - CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`)) ENGINE = MEMORY - SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value, - ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value, - eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, eif6.feature ef6 - FROM tmp so - LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode - AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL - LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode - AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL - LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode - AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL - LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode - AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL - LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode - AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL - LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode - AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL - LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value - LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value - LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value - LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value - LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value - LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value - ORDER BY Price; - - DROP TEMPORARY TABLE tmp; - - - START TRANSACTION; - - -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos - UPDATE IGNORE edi.offer o - JOIN vn.item i - ON i.name = o.product_name - AND i.subname <=> o.company_name - AND i.value5 <=> o.s1Value - AND i.value6 <=> o.s2Value - AND i.value7 <=> o.s3Value - AND i.value8 <=> o.s4Value - AND i.value9 <=> o.s5Value - AND i.value10 <=> o.s6Value - AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask - AND i.EmbalageCode <=> o.EmbalageCode - AND i.quality <=> o.Quality - JOIN vn.itemType it ON it.id = i.typeFk - LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN deliveryInformation di ON di.supplyResponseID = sr.ID - SET i.supplyResponseFk = o.srID - WHERE ( sr.ID IS NULL - OR sr.NumberOfUnits = 0 - OR di.LatestOrderDateTime < NOW() - OR di.ID IS NULL) - AND it.isInventory - ; - -- select now(),'Antes de crear ITO'; - DROP TEMPORARY TABLE IF EXISTS itemToInsert; - CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY - SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk - FROM edi.offer o - LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId - WHERE i.id IS NULL - LIMIT vMaxNewItems; - - -- Reciclado de nº de item - OPEN cur1; - OPEN cur2; - - read_loop: LOOP - - FETCH cur2 INTO vSupplyResponseFk; - FETCH cur1 INTO vFreeId; - - IF done THEN - LEAVE read_loop; - END IF; - - UPDATE itemToInsert - SET itemFk = vFreeId - WHERE srId = vSupplyResponseFk; - - END LOOP; - - CLOSE cur1; - CLOSE cur2; - - -- Insertamos todos los items en Articles de la oferta - INSERT INTO vn.item( id, - `name`, - longName, - subName, - expenceFk, - typeFk, - intrastatFk, - originFk, - supplyResponseFk, - numberOfItemsPerCask, - embalageCode, - quality, - isFloramondo) - SELECT itemFk, - product_name, - product_name, - company_name, - expenseFk, - itemTypeFk, - intrastatFk, - originFk, - `srId`, - NumberOfItemsPerCask, - EmbalageCode, - Quality, - TRUE - FROM itemToInsert; - - INSERT IGNORE INTO vn.itemImageQueue(itemFk, url) - SELECT i.id, PictureReference - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.srId - WHERE PictureReference IS NOT NULL; - - INSERT INTO edi.log(tableName, fieldName,fieldValue) - SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*) - FROM vn.itemImageQueue - WHERE attempts = 0; - - -- Inserta si se añadiesen tags nuevos - INSERT IGNORE INTO vn.tag (name, ediTypeFk) - SELECT description, type_id FROM edi.type; - - -- Inserta los tags sólo en los articulos nuevos - - -- desabilita el trigger para recalcular los tags al final - SET @isTriggerDisabled = TRUE; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.product_name, 1 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Producto' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.Quality, 3 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Calidad' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , ii.company_name, 4 - FROM itemToInsert ii - JOIN vn.tag t ON t.`name` = 'Productor' - JOIN vn.item i ON i.supplyResponseFk = ii.`srId`; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s1Value, 5 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef1 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s1Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s2Value, 6 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef2 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s2Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s3Value, 7 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef3 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s3Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s4Value, 8 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef4 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s4Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s5Value, 9 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef5 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s5Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id , s6Value, 10 - FROM itemToInsert ii - JOIN vn.tag t ON t.ediTypeFk = ii.ef6 - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - WHERE s6Value != ''; - - INSERT INTO vn.itemTag(itemFk, tagFk, value, priority) - SELECT i.id, t.id, ink.name, 11 - FROM itemToInsert ii - JOIN vn.item i ON i.supplyResponseFk = ii.`srId` - JOIN vn.tag t ON t.`name` = 'Color' - JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode - JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1' - JOIN vn.ink ON ink.dutchCode = f.feature_value; - - UPDATE vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId` - JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations - JOIN vn.itemTag diameter ON diameter.itemFk = i.id - JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk - JOIN vn.itemTag size ON size.itemFk = i.id - JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk - SET i.`compression` = - (PI() * POW(diameter.`value`/ 2, 2) * size.`value`) - / - ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask); - - DROP TABLE IF EXISTS tmp.item; - CREATE TABLE tmp.item - (PRIMARY KEY (id)) - SELECT i.id FROM vn.item i - JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`; - - CALL vn.item_refreshTags(); - - SET @isTriggerDisabled = FALSE; - - SELECT MIN(LatestDeliveryDateTime) INTO vLanded - FROM edi.supplyResponse sr - JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID - JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID - JOIN vn.floramondoConfig fc - WHERE mp.isLatestOrderDateTimeRelevant - AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE())); - - UPDATE vn.floramondoConfig - SET nextLanded = vLanded - WHERE vLanded IS NOT NULL; - - - -- Elimina la oferta obsoleta - UPDATE vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel tr ON tr.id = e.travelFk - JOIN vn.agencyMode am ON am.id = tr.agencyFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID - LEFT JOIN edi.putOrder po ON b.deliveryFk = po.deliveryInformationID - LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk - SET b.quantity = 0 - WHERE (di.LatestOrderDateTime < NOW() - OR sr.ID IS NULL - OR sr.NumberOfUnits = 0) - AND am.name = 'LOGIFLORA' - AND e.isRaid; - - -- Localiza las entradas de cada almacen - UPDATE edi.warehouseFloramondo - SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk); - - IF vLanded IS NOT NULL THEN - -- actualiza la oferta existente - UPDATE vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - JOIN vn.item i ON i.id = b.itemFk - JOIN edi.offer o ON i.supplyResponseFk = o.`srId` - SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask, - b.buyingValue = o.price - WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price); - - -- Se eliminan las ofertas ya incluidas en las entradas - DELETE o - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN vn.buy b ON i.id = b.itemFk - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk; - - -- Se inserta el resto - SET vLastInserted := NOW(); - - -- Inserta la oferta - INSERT INTO vn.buy(entryFk, - itemFk, - quantity, - buyingValue, - stickers, - packing, - `grouping`, - groupingMode, - packageFk, - deliveryFk) - - SELECT wf.entryFk, - i.id, - o.NumberOfUnits * o.NumberOfItemsPerCask as quantity, - o.Price, - o.NumberOfUnits as etiquetas, - o.NumberOfItemsPerCask as packing, - GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`, - 2, -- Obliga al Packing - o.embalageCode, - o.diId - FROM edi.offer o - JOIN vn.item i ON i.supplyResponseFk = o.srId - JOIN vn.itemType it ON it.id = i.typeFk - JOIN edi.warehouseFloramondo wf ON wf.isFV = it.isFV OR wf.isFV IS NULL - JOIN vn.packaging p ON p.id LIKE o.embalageCode; -- llevar esta linea i mirar de crear els packages a temps real - - DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - - CREATE TEMPORARY TABLE tmp.buyRecalc - SELECT b.id - FROM vn.buy b - JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk - WHERE b.created >= vLastInserted; - - CALL vn.buy_recalcPrices(); - - END IF; - - DROP TEMPORARY TABLE - edi.offer, - itemToInsert; - - DROP TABLE tmp.item; - - COMMIT; - - -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias - UPDATE vn.item i - SET typeFk = 121 - WHERE i.longName LIKE 'Rosa Garden %' - AND typeFk = 17; - - UPDATE vn.item i - SET typeFk = 156 - WHERE i.longName LIKE 'Rosa ec %' - AND typeFk = 17; - - INSERT INTO edi.log(tableName, fieldName,fieldValue) - VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime)); - - UPDATE vn.floramondoConfig SET LastUpdated = vLastUpdated; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -17137,10 +17379,13 @@ CREATE TABLE `business` ( `date_end` date DEFAULT NULL, `workerBusiness` longtext, `reasonEndFk` int(11) DEFAULT NULL, + `occupationCodeFk` varchar(1) DEFAULT NULL, PRIMARY KEY (`business_id`), KEY `business_client` (`client_id`), KEY `bussiness_provider` (`provider_id`), + KEY `business_occupationCodeFk` (`occupationCodeFk`), CONSTRAINT `business_client` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `business_occupationCodeFk` FOREIGN KEY (`occupationCodeFk`) REFERENCES `vn`.`occupationCode` (`code`) ON UPDATE CASCADE, CONSTRAINT `bussiness_provider` FOREIGN KEY (`provider_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -18098,179 +18343,6 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `movContaCopia` --- - -DROP TABLE IF EXISTS `movContaCopia`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `movContaCopia` ( - `OrdenMovimientos` int(11) NOT NULL DEFAULT '0', - `MovPosicion` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Ejercicio` smallint(6) NOT NULL, - `CodigoEmpresa` smallint(6) NOT NULL, - `Asiento` int(11) NOT NULL, - `CargoAbono` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoCuenta` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Contrapartida` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `FechaAsiento` datetime NOT NULL, - `TipoDocumento` varchar(6) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `DocumentoConta` varchar(9) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Comentario` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `ImporteAsiento` decimal(28,10) NOT NULL, - `CodigoDiario` smallint(6) NOT NULL, - `CodigoCanal` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoActividad` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `FechaVencimiento` datetime NOT NULL, - `NumeroPeriodo` smallint(6) NOT NULL, - `CodigoUsuario` smallint(6) NOT NULL, - `FechaGrabacion` datetime NOT NULL, - `TipoEntrada` varchar(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoDepartamento` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoSeccion` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoDivisa` varchar(3) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `ImporteCambio` decimal(28,10) NOT NULL, - `ImporteDivisa` decimal(28,10) NOT NULL, - `FactorCambio` decimal(28,10) NOT NULL, - `CodigoProyecto` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `LibreN1` int(11) NOT NULL, - `LibreN2` int(11) NOT NULL, - `LibreA1` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `LibreA2` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdDelegacion` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `MovCartera` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, - `IdProcesoIME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `TipoCarteraIME` smallint(6) NOT NULL, - `TipoAnaliticaIME` smallint(6) NOT NULL, - `StatusTraspasadoIME` tinyint(4) NOT NULL, - `TipoImportacionIME` tinyint(4) NOT NULL, - `BaseIva1` decimal(28,10) NOT NULL, - `PorBaseCorrectora1` decimal(28,10) NOT NULL, - `PorIva1` decimal(28,10) NOT NULL, - `CuotaIva1` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia1` decimal(28,10) NOT NULL, - `RecargoEquivalencia1` decimal(28,10) NOT NULL, - `CodigoTransaccion1` tinyint(4) NOT NULL, - `BaseIva2` decimal(28,10) NOT NULL, - `PorBaseCorrectora2` decimal(28,10) NOT NULL, - `PorIva2` decimal(28,10) NOT NULL, - `CuotaIva2` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia2` decimal(28,10) NOT NULL, - `RecargoEquivalencia2` decimal(28,10) NOT NULL, - `CodigoTransaccion2` tinyint(4) NOT NULL, - `BaseIva3` decimal(28,10) NOT NULL, - `PorBaseCorrectora3` decimal(28,10) NOT NULL, - `PorIva3` decimal(28,10) NOT NULL, - `CuotaIva3` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia3` decimal(28,10) NOT NULL, - `RecargoEquivalencia3` decimal(28,10) NOT NULL, - `CodigoTransaccion3` tinyint(4) NOT NULL, - `baseIva4` decimal(28,10) NOT NULL, - `PorBaseCorrectora4` decimal(28,10) NOT NULL, - `PorIva4` decimal(28,10) NOT NULL, - `CuotaIva4` decimal(28,10) NOT NULL, - `PorRecargoEquivalencia4` decimal(28,10) NOT NULL, - `RecargoEquivalencia4` decimal(28,10) NOT NULL, - `CodigoTransaccion4` tinyint(4) NOT NULL, - `Año` smallint(6) NOT NULL, - `Serie` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Factura` int(11) NOT NULL, - `SuFacturaNo` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `FechaFactura` datetime NOT NULL, - `ImporteFactura` decimal(28,10) NOT NULL, - `TipoFactura` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoCuentaFactura` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CifDni` varchar(13) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Nombre` varchar(35) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `CodigoRetencion` smallint(6) NOT NULL, - `BaseRetencion` decimal(28,10) NOT NULL, - `PorRetencion` decimal(28,10) NOT NULL, - `ImporteRetencion` decimal(28,10) NOT NULL, - `AbonoIva` smallint(6) NOT NULL, - `CodigoActividadF` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Intracomunitaria` smallint(6) NOT NULL, - `CodigoTerritorio` smallint(6) NOT NULL, - `SiglaNacion` varchar(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `RetencionInformativa` smallint(6) NOT NULL, - `EjercicioFacturaOriginal` smallint(6) NOT NULL, - `SerieFacturaOriginal` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `NumeroFacturaOriginal` int(11) NOT NULL, - `EjercicioFactura` smallint(6) NOT NULL, - `CobroPagoRetencion` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `FechaOperacion` datetime NOT NULL, - `Exclusion347` smallint(6) NOT NULL, - `MovIdentificadorIME` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Previsiones` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `MantenerAsiento` tinyint(4) NOT NULL, - `OrdenMovIME` smallint(6) NOT NULL, - `Metalico347` smallint(6) NOT NULL, - `ClaveOperacionFactura_` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `SerieAgrupacion_` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `NumeroFacturaInicial_` int(11) NOT NULL, - `NumeroFacturaFinal_` int(11) NOT NULL, - `IdAsientoExterno` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdDiarioExterno` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExterno` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdMovimiento` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdCuadre` smallint(6) NOT NULL, - `FechaCuadre` datetime NOT NULL, - `TipoCuadre` varchar(4) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `AgrupacionCuadre` int(11) NOT NULL, - `StatusSaldo` smallint(6) NOT NULL, - `StatusConciliacion` smallint(6) NOT NULL, - `CodigoConciliacion` int(11) NOT NULL, - `FechaConciliacion` datetime NOT NULL, - `TipoConciliacion` smallint(6) NOT NULL, - `IndicadorContaBanco` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion3` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion4` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion5` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion6` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion7` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion8` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion9` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion2` varchar(250) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Descripcion1` varchar(250) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `Punteo1` smallint(6) NOT NULL, - `Punteo9` smallint(6) NOT NULL, - `Punteo8` smallint(6) NOT NULL, - `Punteo7` smallint(6) NOT NULL, - `Punteo6` smallint(6) NOT NULL, - `Punteo5` smallint(6) NOT NULL, - `Punteo4` smallint(6) NOT NULL, - `Punteo3` smallint(6) NOT NULL, - `Punteo2` smallint(6) NOT NULL, - `CodigoIva1` smallint(6) NOT NULL, - `CodigoIva2` smallint(6) NOT NULL, - `CodigoIva3` smallint(6) NOT NULL, - `CodigoIva4` smallint(6) NOT NULL, - `CriterioIva` tinyint(4) NOT NULL, - `FechaMaxVencimiento` datetime NOT NULL, - `TipoCriterioCaja` tinyint(4) NOT NULL, - `MovFacturaOrigenIME` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoFinal` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoInicial` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IdFacturaExternoOriginal` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `NumFacturasExternoAgrupacion` int(11) NOT NULL, - `CodigoMedioCobro` varchar(1) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `MedioCobro` varchar(31) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `IvaDeducible1` smallint(6) NOT NULL DEFAULT '1', - `IvaDeducible2` smallint(6) NOT NULL DEFAULT '1', - `IvaDeducible3` smallint(6) NOT NULL DEFAULT '1', - `IvaDeducible4` smallint(6) NOT NULL DEFAULT '1', - `TipoRectificativa` smallint(6) NOT NULL, - `FechaFacturaOriginal` datetime NOT NULL, - `BaseImponibleOriginal` decimal(28,10) NOT NULL, - `CuotaIvaOriginal` decimal(28,10) NOT NULL, - `ClaseAbonoRectificativas` smallint(6) NOT NULL, - `RecargoEquivalenciaOriginal` decimal(28,10) NOT NULL, - `ObjetoFactura` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, - `enlazado` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`OrdenMovimientos`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `pgcToSage` -- @@ -18363,11 +18435,11 @@ TRUNCATE TABLE clientesProveedores; Nacion, Telefono, Telefono2, - CodigoTransaccion, + CodigoTransaccion, CodigoRetencion, Email1, iban) - SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) CodigoEmpresa, + SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) CodigoEmpresa, 'C' ClienteOProveedor, cl.id CodigoClienteProveedor, cl.socialName RazonSocial, @@ -18376,25 +18448,25 @@ TRUNCATE TABLE clientesProveedores; cl.accountingAccount CodigoCuenta, TRIM(IF(co.code = LEFT(cl.fi,2), MID(cl.fi,3, length(cl.fi)-1), cl.fi)) AS CifDni, IF(sn.NacionCEE,TRIM(CONCAT(co.code, IF(co.code = LEFT(cl.fi,2), MID(cl.fi,3, length(cl.fi)-1), cl.fi))) , "")AS CifEuropeo, - cl.postcode CodigoPostal, + cl.postcode CodigoPostal, cl.city Municipio, sp.CodigoProvincia CodigoProvincia, p.name Provincia, - IF (sn.SiglaNacion = "XB",IF(sp.CodigoProvincia IN (51,52), 22, IF (sp.CodigoProvincia IN (35,38), 21, sn.CodigoNacion)), sn.CodigoNacion) CodigoNacion, + IF (sn.SiglaNacion = "XB",IF(sp.CodigoProvincia IN (51,52), 22, IF (sp.CodigoProvincia IN (35,38), 21, sn.CodigoNacion)), sn.CodigoNacion) CodigoNacion, IF (sn.SiglaNacion = "XB",IF(sp.CodigoProvincia IN (51,52), "XC",IF (sp.CodigoProvincia IN (35,38), "XB", sn.SiglaNacion)), sn.SiglaNacion) SiglaNacion, IF((cl.fi REGEXP '^([[:blank:]]|[[:digit:]])'), 'J','F') PersonaFisicaJuridica, IF((co.id = 1 OR co.id = 30) OR (co.isUeeMember = 1 AND NOT cl.isVies) , 1, IF((co.isUeeMember = 1 AND cl.isVies), 2, 4)) TipoDocumentoPersona, - -- IF(cl.isEqualizated, 'R', IF ((cl.isVies AND cl.countryFk <> 1) OR (NOT co.isUeeMember),'E','I'))AS CodigoIva, + -- IF(cl.isEqualizated, 'R', IF ((cl.isVies AND cl.countryFk <> 1) OR (NOT co.isUeeMember),'E','I'))AS CodigoIva, cl.taxTypeSageFk CodigoIva, - IF(sn.SiglaNacion = "XB", IF(sp.CodigoProvincia IN (51,52), "CEUTA Y MELILLA", IF (sp.CodigoProvincia IN (35,38), "ISLAS CANARIAS",sn.Nacion)) , sn.Nacion) Nacion, + IF(sn.SiglaNacion = "XB", IF(sp.CodigoProvincia IN (51,52), "CEUTA Y MELILLA", IF (sp.CodigoProvincia IN (35,38), "ISLAS CANARIAS",sn.Nacion)) , sn.Nacion) Nacion, cl.phone Telefono, cl.mobile Telefono2, cl.transactionTypeSageFk CodigoTransaccion, - 0 CodigoRetencion, - SUBSTR(cl.email, 1, LOCATE(',', CONCAT(cl.email,','))-1) Email1, + 0 CodigoRetencion, + SUBSTR(cl.email, 1, LOCATE(',', CONCAT(cl.email,','))-1) Email1, cl.iban iban - FROM vn.client cl + FROM vn.client cl JOIN vn2008.v_xsubclien ON v_xsubclien.Id_Cliente = cl.id LEFT JOIN vn.country co ON co.id = cl.countryFk LEFT JOIN sage.Naciones sn ON sn.countryFk = co.id @@ -18411,23 +18483,23 @@ TRUNCATE TABLE clientesProveedores; s.street Domicilio, s.account CodigoCuenta, TRIM(IF(co.code = LEFT(s.nif,2), MID(s.nif,3, length(s.nif)-1), s.nif)) CifDni, - IF(sn.NacionCEE,TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif,2), MID(s.nif,3, length(s.nif)-1), s.nif))), "") AS CifEuropeo, + IF(sn.NacionCEE,TRIM(CONCAT(co.code, IF(co.code = LEFT(s.nif,2), MID(s.nif,3, length(s.nif)-1), s.nif))), "") AS CifEuropeo, s.postCode CodigoPostal, s.city Municipio, sp.CodigoProvincia CodigoProvincia, p.name Provincia, sn.CodigoNacion CodigoNacion, sn.SiglaNacion SiglaNacion, - IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F') PersonaFisicaJuridica, + IF((s.nif REGEXP '^([[:blank:]]|[[:digit:]])'),'J','F') PersonaFisicaJuridica, IF((co.id = 1 OR co.id = 30),1,IF((co.isUeeMember = 1), 2, 4)) TipoDocumentoPersona, -- 'I' CodigoIva, - s.taxTypeSageFk CodigoIva, + s.taxTypeSageFk CodigoIva, sn.Nacion Nacion, con.Telefono Telefono, con.Movil Telefono2, - s.transactionTypeSageFk CodigoTransaccion, + s.transactionTypeSageFk CodigoTransaccion, s.withholdingSageFk CodigoRetencion, - SUBSTR(con.email,1,(COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)) Email1, + SUBSTR(con.email,1,(COALESCE(NULLIF(LOCATE(',', con.email), 0), 99) - 1)) Email1, sa.iban iban FROM vn.supplier s JOIN vn2008.v_xsubprov xsp ON xsp.proveedor_id = s.id -- Proveedores activos los últimos 3 meses @@ -18463,208 +18535,208 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `movContaAdd`() BEGIN /* Copia en movConta los asientos de XDiario para que luego los importe el proceso automático que hay en SQL Server - */ + */ DECLARE vDated DATE; - SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; + SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; TRUNCATE XDiario_movConta_IVA; DELETE FROM movConta WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - CALL clientesProveedoresAdd; - CALL planCuentasPgcAdd; - CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager; - CALL XDiario_movConta_IVA_InvoiceInAdd_Manager; + CALL clientesProveedoresAdd; + CALL planCuentasPgcAdd; + CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager; + CALL XDiario_movConta_IVA_InvoiceInAdd_Manager; INSERT INTO movConta( - TipoEntrada, -- VARCHAR(2) - Ejercicio, -- Año - CodigoEmpresa, -- ENT(2) - Asiento, -- LONG(4), nº ASIENTO - CargoAbono, -- VARCHAR(1) "D" debe ó "H" haber - CodigoCuenta, -- VARCHAR(15) partida contable - Contrapartida, -- VARCHAR(15) partida contable - FechaAsiento, -- FECHA(8) - Comentario, -- VARCHAR(40) - ImporteAsiento, -- DOBLE(19) - NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento - FechaGrabacion, -- FECHA(8) - CodigoDivisa, -- VARCHAR(3) - ImporteCambio, -- DOBLE(19) - ImporteDivisa, -- DOBLE(19) - FactorCambio, -- DOBLE(19) - IdProcesoIME, -- GUID(16) - TipoCarteraIME, -- ENT(2) "0" para que no genere cartera - TipoAnaliticaIME, -- ENT(2) - StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún - TipoImportacionIME, -- BYTE "0" Alta "1" Baja - Metalico347, -- ENT(2) - /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ - BaseIva1, -- DOBLE(19) - PorBaseCorrectora1, -- DOBLE(19) - PorIva1, -- DOBLE(19) - CuotaIva1, -- DOBLE(19) - PorRecargoEquivalencia1,-- DOBLE(19) - RecargoEquivalencia1, -- DOBLE(19) - CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario - BaseIva2, - PorBaseCorrectora2, - PorIva2, - CuotaIva2, - PorRecargoEquivalencia2, - RecargoEquivalencia2, - CodigoTransaccion2, - BaseIva3, - PorBaseCorrectora3, - PorIva3, - CuotaIva3, - PorRecargoEquivalencia3, - RecargoEquivalencia3, - CodigoTransaccion3, - BaseIva4, - PorBaseCorrectora4, - PorIva4, - CuotaIva4, - PorRecargoEquivalencia4, - RecargoEquivalencia4, - CodigoTransaccion4, - Año, -- ENT(2) - Serie, -- VARCHAR(10) - Factura, -- LONG(4) - SuFacturaNo, -- VARCHAR(40) - FechaFactura, -- FECHA(8) - ImporteFactura, -- DOBLE(19) - TipoFactura, -- VARCHAR(1) "E" / "R" / "I" - CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor - CifDni, -- VARCHAR(13) - Nombre, -- VARCHAR(35) - CodigoRetencion, -- ENT(2) - BaseRetencion, -- DOBLE(19) - PorRetencion, -- DOBLE(19) - ImporteRetencion, -- DOBLE(19) - SiglaNacion, -- VARCHAR(2) "ES" por defecto - EjercicioFactura, -- ENT(2) - FechaOperacion, -- FECHA(8) - Exclusion347, -- ENT(2) - MantenerAsiento, -- BYTE "-1" mantener "0" Sage asigna nuevo - ClaveOperacionFactura_, -- VARCHAR(1) P(4721000011,4721000021)-I(4721000015-4720000005-4720000006)-D (Rectificativas) - TipoRectificativa, -- ENT(2) - FechaFacturaOriginal, -- FECHA(8) - BaseImponibleOriginal, -- DOBLE(19) - CuotaIvaOriginal, -- DOBLE(19) - ClaseAbonoRectificativas,-- ENT(2) - RecargoEquivalenciaOriginal, -- DOBLE(19) */ - LibreA1, - CodigoIva1, -- ENT(6) - CodigoIva2, -- ENT(6) - CodigoIva3, -- ENT(6) - CodigoIva4, -- ENT(6) + TipoEntrada, -- VARCHAR(2) + Ejercicio, -- Año + CodigoEmpresa, -- ENT(2) + Asiento, -- LONG(4), nº ASIENTO + CargoAbono, -- VARCHAR(1) "D" debe ó "H" haber + CodigoCuenta, -- VARCHAR(15) partida contable + Contrapartida, -- VARCHAR(15) partida contable + FechaAsiento, -- FECHA(8) + Comentario, -- VARCHAR(40) + ImporteAsiento, -- DOBLE(19) + NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento + FechaGrabacion, -- FECHA(8) + CodigoDivisa, -- VARCHAR(3) + ImporteCambio, -- DOBLE(19) + ImporteDivisa, -- DOBLE(19) + FactorCambio, -- DOBLE(19) + IdProcesoIME, -- GUID(16) + TipoCarteraIME, -- ENT(2) "0" para que no genere cartera + TipoAnaliticaIME, -- ENT(2) + StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún + TipoImportacionIME, -- BYTE "0" Alta "1" Baja + Metalico347, -- ENT(2) + /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ + BaseIva1, -- DOBLE(19) + PorBaseCorrectora1, -- DOBLE(19) + PorIva1, -- DOBLE(19) + CuotaIva1, -- DOBLE(19) + PorRecargoEquivalencia1,-- DOBLE(19) + RecargoEquivalencia1, -- DOBLE(19) + CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario + BaseIva2, + PorBaseCorrectora2, + PorIva2, + CuotaIva2, + PorRecargoEquivalencia2, + RecargoEquivalencia2, + CodigoTransaccion2, + BaseIva3, + PorBaseCorrectora3, + PorIva3, + CuotaIva3, + PorRecargoEquivalencia3, + RecargoEquivalencia3, + CodigoTransaccion3, + BaseIva4, + PorBaseCorrectora4, + PorIva4, + CuotaIva4, + PorRecargoEquivalencia4, + RecargoEquivalencia4, + CodigoTransaccion4, + Año, -- ENT(2) + Serie, -- VARCHAR(10) + Factura, -- LONG(4) + SuFacturaNo, -- VARCHAR(40) + FechaFactura, -- FECHA(8) + ImporteFactura, -- DOBLE(19) + TipoFactura, -- VARCHAR(1) "E" / "R" / "I" + CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor + CifDni, -- VARCHAR(13) + Nombre, -- VARCHAR(35) + CodigoRetencion, -- ENT(2) + BaseRetencion, -- DOBLE(19) + PorRetencion, -- DOBLE(19) + ImporteRetencion, -- DOBLE(19) + SiglaNacion, -- VARCHAR(2) "ES" por defecto + EjercicioFactura, -- ENT(2) + FechaOperacion, -- FECHA(8) + Exclusion347, -- ENT(2) + MantenerAsiento, -- BYTE "-1" mantener "0" Sage asigna nuevo + ClaveOperacionFactura_, -- VARCHAR(1) P(4721000011,4721000021)-I(4721000015-4720000005-4720000006)-D (Rectificativas) + TipoRectificativa, -- ENT(2) + FechaFacturaOriginal, -- FECHA(8) + BaseImponibleOriginal, -- DOBLE(19) + CuotaIvaOriginal, -- DOBLE(19) + ClaseAbonoRectificativas,-- ENT(2) + RecargoEquivalenciaOriginal, -- DOBLE(19) */ + LibreA1, + CodigoIva1, -- ENT(6) + CodigoIva2, -- ENT(6) + CodigoIva3, -- ENT(6) + CodigoIva4, -- ENT(6) IvaDeducible1, -- Entero 2 ((-1)) IvaDeducible2, -- Entero 2 ((-1)) IvaDeducible3, -- Entero 2 ((-1)) IvaDeducible4, -- Entero 2 ((-1))-- ENT(6) - Intracomunitaria -- INT(2) - ) - SELECT 'EN' as TipoEntrada, + Intracomunitaria -- INT(2) + ) + SELECT 'EN' as TipoEntrada, YEAR(x.FECHA) AS Ejercicio, - IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa, -- ENT(2) c.companyCode AS CodigoEmpresa, - x.ASIEN AS Asiento, -- LONG(4), nº ASIENTO - IF(EURODEBE<>0 OR (EURODEBE=0 AND EUROHABER IS NULL),'D','H')AS CargoAbono, -- IF(EURODEBE IS NULL,"H","D") AS CargoAbono, VARCHAR(1) "D" debe ó "H" haber - x.SUBCTA AS CodigoCuenta, -- VARCHAR(15) partida contable - x.CONTRA AS Contrapartida, -- VARCHAR(15) partida contable - x.FECHA AS FechaAsiento, -- FECHA(8) - SUBSTRING(x.CONCEPTO, 1, 40) AS Comentario, -- VARCHAR(40) - IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19) - MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento - IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8) - IF(x.CAMBIO,IFNULL(xmi.CodigoDivisa, sub3.code),'') CodigoDivisa, -- VARCHAR(3) - x.CAMBIO AS ImporteCambio, -- DOBLE(19) - IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19) - IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19) - NULL AS IdProcesoIME, -- GUID(16) - 0 AS TipoCarteraIME, -- ENT(2) "0" para que no genere cartera - 0 AS TipoAnaliticaIME, -- ENT(2) - 0 AS StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún - 0 AS TipoImportacionIME, -- BYTE "0" Alta "1" Baja - x.METAL as Metalico347, - /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ - xmi.BaseIva1, -- DOBLE(19) - xmi.PorBaseCorrectora1, -- DOBLE(19) - xmi.PorIva1, -- DOBLE(19) - xmi.CuotaIva1, -- DOBLE(19) - xmi.PorRecargoEquivalencia1,-- DOBLE(19) - xmi.RecargoEquivalencia1, -- DOBLE(19) - xmi.CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario - xmi.BaseIva2, - xmi.PorBaseCorrectora2, - xmi.PorIva2, - xmi.CuotaIva2, - xmi.PorRecargoEquivalencia2, - xmi.RecargoEquivalencia2, - xmi.CodigoTransaccion2, - xmi.BaseIva3, - xmi.PorBaseCorrectora3, - xmi.PorIva3, - xmi.CuotaIva3, - xmi.PorRecargoEquivalencia3, - xmi.RecargoEquivalencia3, - xmi.CodigoTransaccion3, - xmi.BaseIva4, - xmi.PorBaseCorrectora4, - xmi.PorIva4, - xmi.CuotaIva4, - xmi.PorRecargoEquivalencia4, - xmi.RecargoEquivalencia4, - xmi.CodigoTransaccion4, - xmi.Año, -- ENT(2) - xmi.Serie, -- VARCHAR(10) - xmi.Factura, -- LONG(4) - xmi.SuFacturaNo, -- VARCHAR(40) - xmi.FechaFactura, -- FECHA(8) - xmi.ImporteFactura, -- DOBLE(19) - xmi.TipoFactura, -- VARCHAR(1) "E" / "R" - xmi.CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor - xmi.CifDni, -- VARCHAR(13) - xmi.Nombre, -- VARCHAR(35) - xmi.CodigoRetencion, -- ENT(2) - xmi.BaseRetencion, -- DOBLE(19) - xmi.PorRetencion, -- DOBLE(19) - xmi.ImporteRetencion, -- DOBLE(19) - xmi.SiglaNacion, -- VARCHAR(2) "ES" por defecto - xmi.EjercicioFactura, -- ENT(2) - xmi.FechaOperacion, -- FECHA(8) - xmi.Exclusion347, -- ENT(2) - 1, -- xmi.MantenerAsiento BYTE "-1" mantener "0" Sage asigna nuevo - xmi.ClaveOperacionFactura, -- VARCHAR(1) - xmi.TipoRectificativa, -- ENT(2) - xmi.FechaFacturaOriginal, -- FECHA(8) - xmi.BaseImponibleOriginal, -- DOBLE(19) - xmi.CuotaIvaOriginal, -- DOBLE(19) - xmi.ClaseAbonoRectificativas,-- ENT(2) - xmi.RecargoEquivalenciaOriginal,-- DOBLE(19) */ - xmi.LibreA1, - xmi.CodigoIva1, -- ENT(6) - xmi.CodigoIva2, -- ENT(6) - xmi.CodigoIva3, -- ENT(6) - xmi.CodigoIva4, -- ENT(6) + IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa, -- ENT(2) c.companyCode AS CodigoEmpresa, + x.ASIEN AS Asiento, -- LONG(4), nº ASIENTO + IF(EURODEBE<>0 OR (EURODEBE=0 AND EUROHABER IS NULL),'D','H')AS CargoAbono, -- IF(EURODEBE IS NULL,"H","D") AS CargoAbono, VARCHAR(1) "D" debe ó "H" haber + x.SUBCTA AS CodigoCuenta, -- VARCHAR(15) partida contable + x.CONTRA AS Contrapartida, -- VARCHAR(15) partida contable + x.FECHA AS FechaAsiento, -- FECHA(8) + SUBSTRING(x.CONCEPTO, 1, 40) AS Comentario, -- VARCHAR(40) + IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19) + MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento + IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8) + IF(x.CAMBIO,IFNULL(xmi.CodigoDivisa, sub3.code),'') CodigoDivisa, -- VARCHAR(3) + x.CAMBIO AS ImporteCambio, -- DOBLE(19) + IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19) + IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19) + NULL AS IdProcesoIME, -- GUID(16) + 0 AS TipoCarteraIME, -- ENT(2) "0" para que no genere cartera + 0 AS TipoAnaliticaIME, -- ENT(2) + 0 AS StatusTraspasadoIME, -- BYTE "0" para dejar como no importado aún + 0 AS TipoImportacionIME, -- BYTE "0" Alta "1" Baja + x.METAL as Metalico347, + /* ESTOS CAMPOS SOLO SE INFORMAN EN EL CASO DE SER FACTURA */ + xmi.BaseIva1, -- DOBLE(19) + xmi.PorBaseCorrectora1, -- DOBLE(19) + xmi.PorIva1, -- DOBLE(19) + xmi.CuotaIva1, -- DOBLE(19) + xmi.PorRecargoEquivalencia1,-- DOBLE(19) + xmi.RecargoEquivalencia1, -- DOBLE(19) + xmi.CodigoTransaccion1, -- BYTE "0" Nacional "1" Intracomunitario "2" Extracomunitario + xmi.BaseIva2, + xmi.PorBaseCorrectora2, + xmi.PorIva2, + xmi.CuotaIva2, + xmi.PorRecargoEquivalencia2, + xmi.RecargoEquivalencia2, + xmi.CodigoTransaccion2, + xmi.BaseIva3, + xmi.PorBaseCorrectora3, + xmi.PorIva3, + xmi.CuotaIva3, + xmi.PorRecargoEquivalencia3, + xmi.RecargoEquivalencia3, + xmi.CodigoTransaccion3, + xmi.BaseIva4, + xmi.PorBaseCorrectora4, + xmi.PorIva4, + xmi.CuotaIva4, + xmi.PorRecargoEquivalencia4, + xmi.RecargoEquivalencia4, + xmi.CodigoTransaccion4, + xmi.Año, -- ENT(2) + xmi.Serie, -- VARCHAR(10) + xmi.Factura, -- LONG(4) + xmi.SuFacturaNo, -- VARCHAR(40) + xmi.FechaFactura, -- FECHA(8) + xmi.ImporteFactura, -- DOBLE(19) + xmi.TipoFactura, -- VARCHAR(1) "E" / "R" + xmi.CodigoCuentaFactura, -- VARCHAR(15) cuenta del cliente/proveedor + xmi.CifDni, -- VARCHAR(13) + xmi.Nombre, -- VARCHAR(35) + xmi.CodigoRetencion, -- ENT(2) + xmi.BaseRetencion, -- DOBLE(19) + xmi.PorRetencion, -- DOBLE(19) + xmi.ImporteRetencion, -- DOBLE(19) + xmi.SiglaNacion, -- VARCHAR(2) "ES" por defecto + xmi.EjercicioFactura, -- ENT(2) + xmi.FechaOperacion, -- FECHA(8) + xmi.Exclusion347, -- ENT(2) + 1, -- xmi.MantenerAsiento BYTE "-1" mantener "0" Sage asigna nuevo + xmi.ClaveOperacionFactura, -- VARCHAR(1) + xmi.TipoRectificativa, -- ENT(2) + xmi.FechaFacturaOriginal, -- FECHA(8) + xmi.BaseImponibleOriginal, -- DOBLE(19) + xmi.CuotaIvaOriginal, -- DOBLE(19) + xmi.ClaseAbonoRectificativas,-- ENT(2) + xmi.RecargoEquivalenciaOriginal,-- DOBLE(19) */ + xmi.LibreA1, + xmi.CodigoIva1, -- ENT(6) + xmi.CodigoIva2, -- ENT(6) + xmi.CodigoIva3, -- ENT(6) + xmi.CodigoIva4, -- ENT(6) xmi.IvaDeducible1, -- Entero 2 ((-1)) xmi.IvaDeducible2, -- Entero 2 ((-1)) xmi.IvaDeducible3, -- Entero 2 ((-1)) xmi.IvaDeducible4, -- Entero 2 ((-1))-- ENT(6) - xmi.Intracomunitaria -- TINYINT(1) - FROM vn2008.XDiario x - JOIN vn.company c ON c.id = x.empresa_id - LEFT JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData > 0 - LEFT JOIN (SELECT ASIEN, FECREGCON, FECHA_EX + xmi.Intracomunitaria -- TINYINT(1) + FROM vn2008.XDiario x + JOIN vn.company c ON c.id = x.empresa_id + LEFT JOIN XDiario_movConta_IVA xmi ON xmi.id = x.id AND xmi.moveData > 0 + LEFT JOIN (SELECT ASIEN, FECREGCON, FECHA_EX FROM (SELECT ASIEN, FECREGCON, FECHA_EX FROM vn2008.XDiario ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC ) sub GROUP BY ASIEN )sub2 ON sub2.ASIEN = x.ASIEN - LEFT JOIN ( SELECT DISTINCT(account),cu.code + LEFT JOIN ( SELECT DISTINCT(account),cu.code FROM vn.bank b JOIN vn.currency cu ON cu.id = b.currencyFk - WHERE cu.code <> "EUR" -- no se informa cuando la divisa en EUR - )sub3 ON sub3.account = x.SUBCTA + WHERE cu.code <> "EUR" -- no se informa cuando la divisa en EUR + )sub3 ON sub3.account = x.SUBCTA WHERE x.enlazadoSage = 0 AND c.companyCode AND - x.FECHA >= vDated; + x.FECHA >= vDated; -- Prepara Metálicos UPDATE sage.movConta m @@ -18684,10 +18756,10 @@ BEGIN UPDATE sage.movConta m SET Metalico347 = FALSE, - m.TipoFactura = "", - m.Metalico347 = FALSE + m.TipoFactura = "", + m.Metalico347 = FALSE WHERE CargoAbono = "D" AND - m.enlazadoSage = FALSE; + m.enlazadoSage = FALSE; -- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación DELETE cp @@ -18720,12 +18792,13 @@ BEGIN m.IvaDeducible1 = TRUE, m.FechaFacturaOriginal = x.FECHA_EX, m.SuFacturaNo = x.FACTURAEX, - m.FechaOperacion = x.FECHA_OP + m.FechaOperacion = x.FECHA_OP, + m.ImporteFactura = m.ImporteFactura + x.BASEEURO + (x.IVA/100) * x.BASEEURO WHERE m.CodigoCuenta = 4700000999 AND m.enlazadoSage = FALSE AND x.SERIE='D' AND x.IVA = 10; - + UPDATE movConta m JOIN vn.XDiario x ON x.ASIEN = m.Asiento SET m.BaseIva2 = x.BASEEURO , @@ -18733,7 +18806,8 @@ BEGIN m.CuotaIva2 = (x.IVA/100) * x.BASEEURO , m.CodigoTransaccion2 = 56 , m.CodigoIva2 = 90, - m.IvaDeducible2 = TRUE + m.IvaDeducible2 = TRUE, + m.ImporteFactura = m.ImporteFactura + x.BASEEURO + (x.IVA/100) * x.BASEEURO WHERE m.CodigoCuenta = 4700000999 AND m.enlazadoSage = FALSE AND x.SERIE='D' @@ -18750,79 +18824,86 @@ UPDATE movConta m GROUP BY x.ASIEN ) sub ON sub.ASIEN = m.Asiento SET m.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT), - m.SerieFacturaOriginal = sub.SERIE_RT, - m.NumeroFacturaOriginal = sub.FACTU_RT + m.SerieFacturaOriginal = sub.SERIE_RT, + m.NumeroFacturaOriginal = sub.FACTU_RT WHERE m.TipoRectificativa > 0 AND - m.enlazadoSage = FALSE ; + m.enlazadoSage = FALSE ; -- Exportaciones Andorras y Canarias cambia TT (la cuenta de taxCode es compartida, id:125) UPDATE sage.movConta m - SET CodigoTransaccion1 = 15, + SET CodigoTransaccion1 = 15, CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, 15), - CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, 15), - CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, 15) - WHERE enlazadoSage = FALSE AND + CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, 15), + CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, 15) + WHERE enlazadoSage = FALSE AND (CodigoTransaccion1 = 14 OR CodigoTransaccion2 = 14 OR CodigoTransaccion3 = 14 OR CodigoTransaccion4 = 14) AND - SiglaNAcion IN ('XC','XB'); - - + SiglaNAcion IN ('XC','XB'); -- Divisas - UPDATE sage.movConta - SET CodigoDivisa = IF(ImporteCambio<>0, "USD", "") - WHERE enlazadoSage = FALSE AND - ImporteCambio<>0 AND - ImporteDivisa<>0; - - + + UPDATE sage.movConta mc + SET CodigoDivisa = 'USD', + FactorCambio = 1, + ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio=0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2))) + WHERE (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio <> 0) + AND enlazadoSage = FALSE ; + + UPDATE sage.movConta mc + SET importeDivisa= importeDivisa * -1 + WHERE enlazadoSage = FALSE + AND importeDivisa > 0 + AND ImporteAsiento < 0; + + + /*-- Actualiza las facturas DUA para excluirlas del 347 y marcarlas como intracomunitarias /*UPDATE sage.movConta mc SET mc.Intracomunitaria = 1, mc.Exclusion347 = 1 WHERE - mc.CodigoCuenta = '4700000999'; */ + mc.CodigoCuenta = '4700000999'; */ - + -- MARCAR EN CASO DE SER INTRACOMUNITARIA -/* +/* UPDATE sage.movConta mc SET mc.Intracomunitaria = 1 WHERE - mc.CodigoTransaccion1 IN (20,29); + mc.CodigoTransaccion1 IN (20,29); */ - + -- LAS FACTURAS RTECTIFICATIVAS QUE TIENEN CUENTA DE IVA 477.2 SALE CON T.T. 1, TODAS ESTAS FACTURAS DEBEN DE TENER T.T. 15 /*UPDATE sage.movConta mc - JOIN - (SELECT - Asiento - FROM - sage.movConta - WHERE - CodigoCuenta = 4770000002) sub ON sub.Asiento = mc.Asiento + JOIN + (SELECT + Asiento + FROM + sage.movConta + WHERE + CodigoCuenta = 4770000002) sub ON sub.Asiento = mc.Asiento SET - CodigoTransaccion1 = CASE - WHEN CodigoTransaccion1 = 1 THEN 15 - ELSE CodigoTransaccion1 - END, - CodigoTransaccion2 = CASE - WHEN CodigoTransaccion2 = 1 THEN 15 - ELSE CodigoTransaccion2 - END, - CodigoTransaccion3 = CASE - WHEN CodigoTransaccion3 = 1 THEN 15 - ELSE CodigoTransaccion3 - END, - CodigoTransaccion4 = CASE - WHEN CodigoTransaccion4 = 1 THEN 15 - ELSE CodigoTransaccion4 - END + CodigoTransaccion1 = CASE + WHEN CodigoTransaccion1 = 1 THEN 15 + ELSE CodigoTransaccion1 + END, + CodigoTransaccion2 = CASE + WHEN CodigoTransaccion2 = 1 THEN 15 + ELSE CodigoTransaccion2 + END, + CodigoTransaccion3 = CASE + WHEN CodigoTransaccion3 = 1 THEN 15 + ELSE CodigoTransaccion3 + END, + CodigoTransaccion4 = CASE + WHEN CodigoTransaccion4 = 1 THEN 15 + ELSE CodigoTransaccion4 + END WHERE - serie = 'R'; + serie = 'R'; */ @@ -20039,10 +20120,10 @@ REPLACE INTO planCuentasPGC( CodigoCuenta, Cuenta, ClienteOProveedor - ) + ) SELECT codigoEmpresa, CodigoCuenta, Cuenta, ClienteOProveedor - FROM - ( + FROM + ( SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS codigoEmpresa, e.id AS CodigoCuenta, @@ -20054,9 +20135,9 @@ REPLACE INTO planCuentasPGC( WHERE c.companyCode GROUP BY e.id - + UNION - SELECT + SELECT IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS codigoEmpresa, b.account AS CodigoCuenta, UCASE(b.bank) AS Cuenta, @@ -20068,7 +20149,7 @@ REPLACE INTO planCuentasPGC( AND b.account GROUP BY b.account UNION - SELECT + SELECT codigoEmpresa, CodigoCuenta, Nombre AS Cuenta, @@ -20099,26 +20180,26 @@ BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; - DECLARE vVat DOUBLE; - DECLARE vRate DOUBLE; - DECLARE vTransactionCode INT; - DECLARE vCounter INT DEFAULT 0; - DECLARE vTransactionCodeOld INT; + DECLARE vVat DOUBLE; + DECLARE vRate DOUBLE; + DECLARE vTransactionCode INT; + DECLARE vCounter INT DEFAULT 0; + DECLARE vTransactionCodeOld INT; DECLARE vTaxCode INT; DECLARE vTaxCodeOld INT; - DECLARE vOperationCode VARCHAR(1); + DECLARE vOperationCode VARCHAR(1); DECLARE vIsIntracommunity BOOL DEFAULT FALSE; - DECLARE vDuaExcluded INT; - + DECLARE vDuaExcluded INT; + DECLARE rs CURSOR FOR -- IVA - SELECT it.taxableBase BASEEURO, - CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)) vat, - t.PorcentajeIva rate, - it.transactionTypeSageFk transactionCode, - it.taxTypeSageFk taxCode, - t.isIntracommunity, - tt.ClaveOperacionDefecto operationCode, - id.id + SELECT it.taxableBase BASEEURO, + CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)) vat, + t.PorcentajeIva rate, + it.transactionTypeSageFk transactionCode, + it.taxTypeSageFk taxCode, + t.isIntracommunity, + tt.ClaveOperacionDefecto operationCode, + id.id FROM vn.invoiceIn i JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk @@ -20128,13 +20209,13 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DELETE FROM XDiario_movConta_IVA + DELETE FROM XDiario_movConta_IVA WHERE id = vXDiarioId; - + INSERT INTO XDiario_movConta_IVA(id, LibreA1) VALUES (vXDiarioId, vInvoiceInFk); - OPEN rs; + OPEN rs; FETCH rs INTO vBase, vVat, vRate, @@ -20146,7 +20227,7 @@ BEGIN SET vTransactionCodeOld=vTransactionCode; SET vTaxCodeOld=vTaxCode; - + WHILE NOT vDone DO IF vOperationCode IS NOT NULL THEN UPDATE XDiario_movConta_IVA @@ -20220,18 +20301,21 @@ BEGIN END WHILE; CLOSE rs; - UPDATE XDiario_movConta_IVA xmi + UPDATE XDiario_movConta_IVA xmi JOIN tmp.invoiceInList ii ON ii.id = vInvoiceInFk JOIN vn2008.XDiario x ON x.id = xmi.id - LEFT JOIN tmp.invoiceDua id ON id.id = xmi.id - JOIN vn.supplier s ON s.id = ii.supplierFk + LEFT JOIN tmp.invoiceDua id ON id.id = xmi.id + JOIN vn.supplier s ON s.id = ii.supplierFk JOIN Naciones n ON n.countryFk = s.countryFk SET xmi.CodigoDivisa = ii.currencyFk, xmi.Año = YEAR(ii.issued), xmi.Serie = ii.serial, xmi.Factura = ii.serialNumber, -- x.FACTURA, DUAS¿? xmi.FechaFactura = ii.issued, - xmi.ImporteFactura = BaseIva1 + CuotaIva1 + BaseIva2 + CuotaIva2 + BaseIva3 + CuotaIva3 + BaseIva4 + CuotaIva4, + xmi.ImporteFactura = IFNULL(xmi.BaseIva1, 0) + IFNULL(xmi.CuotaIva1, 0) + + IFNULL(xmi.BaseIva2, 0) + IFNULL(xmi.CuotaIva2, 0) + + IFNULL(xmi.BaseIva3, 0) + IFNULL(xmi.CuotaIva3, 0) + + IFNULL(xmi.BaseIva4, 0) + IFNULL(xmi.CuotaIva4, 0), xmi.TipoFactura = IF(id.id,IF( ii.serial = 'D', 'R','I'), 'R'), -- MARCAR I para informativa xmi.CodigoCuentaFactura = x.SUBCTA, xmi.CifDni = IF(LEFT(TRIM(s.nif),2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif),3) ,s.nif), @@ -20240,43 +20324,43 @@ BEGIN xmi.EjercicioFactura = YEAR(ii.issued), xmi.FechaOperacion = ii.issued, xmi.MantenerAsiento = TRUE, - xmi.SuFacturaNo = ii.supplierRef, - xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva1,FALSE),FALSE,ii.isVatDeductible)), - xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva2,FALSE),FALSE,ii.isVatDeductible)), - xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva3,FALSE),FALSE,ii.isVatDeductible)), - xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva4,FALSE),FALSE,ii.isVatDeductible)), - xmi.FechaFacturaOriginal = x.FECHA_EX + xmi.SuFacturaNo = ii.supplierRef, + xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva1,FALSE),FALSE,ii.isVatDeductible)), + xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva2,FALSE),FALSE,ii.isVatDeductible)), + xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva3,FALSE),FALSE,ii.isVatDeductible)), + xmi.IvaDeducible1 = IF(id.id,FALSE,IF(IFNULL(xmi.BaseIva4,FALSE),FALSE,ii.isVatDeductible)), + xmi.FechaFacturaOriginal = x.FECHA_EX WHERE xmi.id = vXDiarioId; - + -- RETENCIONES /* UPDATE XDiario_movConta_IVA xmi JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk JOIN vn2008.XDiario x ON x.id = xmi.id - JOIN vn.supplier s ON s.id = supplierFk + JOIN vn.supplier s ON s.id = supplierFk JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk + JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk SET xmi.CodigoRetencion = t.CodigoRetencion, xmi.BaseRetencion = iit.taxableBase, xmi.PorRetencion = t.PorcentajeRetencion, - xmi.ImporteRetencion = iit.taxableBase * (t.PorcentajeRetencion / 100) + xmi.ImporteRetencion = iit.taxableBase * (t.PorcentajeRetencion / 100) WHERE xmi.id = vXDiarioId AND iit.taxableBase < 0 ;*/ - - UPDATE XDiario_movConta_IVA xmi + + UPDATE XDiario_movConta_IVA xmi JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk JOIN vn2008.XDiario x ON x.id = xmi.id - JOIN vn.supplier s ON s.id = supplierFk + JOIN vn.supplier s ON s.id = supplierFk JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk - JOIN (SELECT SUM(BASEEURO) taxableBase, SUM(EURODEBE) taxBase + JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk + JOIN (SELECT SUM(BASEEURO) taxableBase, SUM(EURODEBE) taxBase FROM vn.XDiario - WHERE BASEEURO <> 0 AND ASIEN = (SELECT ASIEN FROM vn.XDiario WHERE id = vXDiarioId) + WHERE BASEEURO <> 0 AND ASIEN = (SELECT ASIEN FROM vn.XDiario WHERE id = vXDiarioId) )sub SET xmi.CodigoRetencion = t.CodigoRetencion, - xmi.BaseRetencion = IF (t.CodigoRetencion = 2, sub.taxableBase + sub.taxBase, sub.taxableBase), + xmi.BaseRetencion = IF (t.CodigoRetencion = 2, sub.taxableBase + sub.taxBase, sub.taxableBase), xmi.PorRetencion = t.PorcentajeRetencion, - xmi.ImporteRetencion = iit.taxableBase * - 1 + xmi.ImporteRetencion = iit.taxableBase * - 1 WHERE xmi.id = vXDiarioId AND iit.expenceFk= 4751000000 ; - + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -20651,10 +20735,10 @@ CREATE DEFINER=`root`@`%` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager`( BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; - DECLARE vXDiarioFk INT; - DECLARE vDated DATE; + DECLARE vXDiarioFk INT; + DECLARE vDated DATE; DECLARE rs CURSOR FOR - SELECT IFNULL(ii.id,x.FACTURA) invoiceInFk, x.id XDiarioFk + SELECT IFNULL(x.CLAVE,x.FACTURA) invoiceInFk, x.id XDiarioFk FROM vn2008.XDiario x JOIN(SELECT DISTINCT (x.ASIEN) FROM vn2008.XDiario x @@ -20664,28 +20748,26 @@ BEGIN x.enlazadoSage = FALSE AND x.FECHA >= vDated ) sub ON sub.ASIEN =x.ASIEN -- Elimina las Facturas con IVA 0 (-) no se trasladan a sage - LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id WHERE x.enlazadoSage = FALSE AND x.FECHA >= vDated AND - ii.id IS NOT NULL ; + x.CLAVE IS NOT NULL ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; - DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; + SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; CREATE TEMPORARY TABLE tmp.invoiceDua SELECT id - FROM vn2008.XDiario x - WHERE ASIEN IN (SELECT ASIEN - FROM vn.invoiceIn ii - JOIN vn2008.XDiario x ON x.CLAVE = ii.id - WHERE x.enlazadoSage = FALSE AND - x.SUBCTA = '4700000999' AND - x.FECHA >= vDated - ) AND - NOT CONTRA <=> "4330002067"; + FROM vn2008.XDiario x + WHERE ASIEN IN (SELECT ASIEN + FROM vn2008.XDiario x + WHERE x.enlazadoSage = FALSE AND + x.SUBCTA = '4700000999' AND + x.FECHA >= vDated + ) AND + NOT CONTRA <=> "4330002067"; - DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList; + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList; CREATE TEMPORARY TABLE tmp.invoiceInList SELECT i.id id, i.supplierRef supplierRef, @@ -20699,7 +20781,7 @@ BEGIN JOIN vn.currency c ON c.id = i.currencyFk WHERE i.bookEntried >= vDated UNION ALL - SELECT d.id , + SELECT d.id , d.code , 'D' , d.companyFk , @@ -20718,11 +20800,11 @@ BEGIN FETCH rs INTO vInvoiceFk, vXDiarioFk; END WHILE; CLOSE rs; - + DROP TEMPORARY TABLE tmp.invoiceDua; DROP TEMPORARY TABLE tmp.invoiceInList; - - -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida + + -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida DROP TEMPORARY TABLE IF EXISTS tmp.XDiario_movConta_IVA; CREATE TEMPORARY TABLE tmp.XDiario_movConta_IVA SELECT @@ -20804,7 +20886,7 @@ BEGIN FROM vn.XDiario x WHERE SUBCTA LIKE '472%' AND x.enlazadoSage = FALSE AND - x.FECHA >= vDated + x.FECHA >= vDated ) sub JOIN vn.XDiario x ON x.ASIEN = sub.ASIEN WHERE x.SUBCTA LIKE '477%' )sub2 ON sub2.ASIEN = x.ASIEN @@ -20884,7 +20966,7 @@ BEGIN `moveData`) SELECT * FROM tmp.XDiario_movConta_IVA; - DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA; + DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA; END ;; DELIMITER ; @@ -21160,69 +21242,243 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `XDiario_movConta_IVA_InvoiceInAdd_Manager___`() BEGIN - DECLARE done BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; DECLARE vXDiarioFk INT; + DECLARE vDated DATE; DECLARE rs CURSOR FOR SELECT IFNULL(ii.id,x.FACTURA) invoiceInFk, x.id XDiarioFk FROM vn2008.XDiario x - LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id - WHERE x.enlazadoSage=0 - AND ((SUBCTA<>"4700000999" AND ii.id IS NOT NULL) - OR (SUBCTA LIKE '472%' AND CONTRA ='4330002067' AND ii.id IS NULL)) ; - -/*VALORAR QUITAR LAS FACTURAS CON IVA 0 - FROM vn.invoiceInTax iit - JOIN vn.taxCode tx ON tx.id = iit.taxCodeFk - WHERE iit.rate <> 0 -*/ + JOIN(SELECT DISTINCT (x.ASIEN) + FROM vn2008.XDiario x + LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id + LEFT JOIN vn.invoiceInTax it ON it.invoiceInFk = ii.id + WHERE it.taxTypeSageFk IS NOT NULL AND + x.enlazadoSage = FALSE AND + x.FECHA >= vDated + ) sub ON sub.ASIEN =x.ASIEN -- Elimina las Facturas con IVA 0 (-) no se trasladan a sage + LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id + WHERE x.enlazadoSage = FALSE AND + x.FECHA >= vDated AND + ii.id IS NOT NULL ; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; DROP TEMPORARY TABLE IF EXISTS tmp.invoiceDua; - CREATE TEMPORARY TABLE tmp.invoiceDua SELECT id FROM vn2008.XDiario x WHERE ASIEN IN (SELECT ASIEN FROM vn.invoiceIn ii JOIN vn2008.XDiario x ON x.CLAVE = ii.id - WHERE enlazadoSage=0 AND - SUBCTA = '4700000999' - ) - AND (CONTRA <> "4330002067" OR CONTRA IS NULL); - + WHERE x.enlazadoSage = FALSE AND + x.SUBCTA = '4700000999' AND + x.FECHA >= vDated + ) AND + NOT CONTRA <=> "4330002067"; + + DROP TEMPORARY TABLE IF EXISTS tmp.invoiceInList; + CREATE TEMPORARY TABLE tmp.invoiceInList + SELECT i.id id, + i.supplierRef supplierRef, + i.serial serial, + i.supplierFk supplierFk, + i.issued issued, + i.isVatDeductible isVatDeductible, + i.serialNumber serialNumber, + IF(c.code = "EUR", '',c.code) currencyFk + FROM vn.invoiceIn i + JOIN vn.currency c ON c.id = i.currencyFk + WHERE i.bookEntried >= vDated + UNION ALL + SELECT d.id , + d.code , + 'D' , + d.companyFk , + d.issued , + FALSE, + d.id, + '' -- EUROS + FROM vn.dua d + WHERE d.issued IS NOT NULL AND + code IS NOT NULL; + OPEN rs; FETCH rs INTO vInvoiceFk, vXDiarioFk; - WHILE NOT done DO - CALL XDiario_movConta_IVA_InvoiceInAdd(vInvoiceFk, vXDiarioFk); FETCH rs INTO vInvoiceFk, vXDiarioFk; - END WHILE; - CLOSE rs; + + DROP TEMPORARY TABLE tmp.invoiceDua; + DROP TEMPORARY TABLE tmp.invoiceInList; - DROP TEMPORARY TABLE tmp.invoiceDua; - - DELETE xmi - FROM sage.XDiario_movConta_IVA xmi - JOIN ( SELECT sub.invoiceIn invoiceIn, XDiarioFk, SUM(total) total, tipo - FROM (SELECT IFNULL(ii.id,x.FACTURA) invoiceIn, x.id XDiarioFk,tc.type tipo, 1 as total - FROM vn2008.XDiario x - LEFT JOIN vn.invoiceIn ii ON x.CLAVE = ii.id - LEFT JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - LEFT JOIN vn.taxCode tc ON tc.id = iit.taxCodeFk - WHERE x.enlazadoSage = 0 AND - ((SUBCTA<>"4700000999" AND ii.id IS NOT NULL) OR - (SUBCTA LIKE '472%' AND CONTRA ='4330002067' AND ii.id IS NULL)) AND - serial='R' - GROUP BY invoiceIn, XDiarioFk,tc.type - )sub - GROUP BY sub.invoiceIn, sub.XDiarioFk - HAVING tipo='-' AND total=1 - ) sub2 ON sub2.invoiceIn = xmi.LibreA1 AND sub2.XDiarioFk = xmi.id ; + -- ASIENTOS CON IVA SOPORTADO 472. y 477. hay que informar 2 líneas la info de facturas una como tipo de factura emitida y otra como recibida + DROP TEMPORARY TABLE IF EXISTS tmp.XDiario_movConta_IVA; + CREATE TEMPORARY TABLE tmp.XDiario_movConta_IVA + SELECT + sub3.id, + mc.CodigoDivisa, + mc.BaseIva1, + mc.PorBaseCorrectora1, + mc.PorIva1, + mc.CuotaIva1, + mc.PorRecargoEquivalencia1, + mc.RecargoEquivalencia1, + mc.CodigoTransaccion1, + mc.CodigoIva1, + mc.BaseIva2, + mc.PorBaseCorrectora2, + mc.PorIva2, + mc.CuotaIva2, + mc.PorRecargoEquivalencia2, + mc.RecargoEquivalencia2, + mc.CodigoTransaccion2, + mc.CodigoIva2, + mc.BaseIva3, + mc.PorBaseCorrectora3, + mc.PorIva3, + mc.CuotaIva3, + mc.PorRecargoEquivalencia3, + mc.RecargoEquivalencia3, + mc.CodigoTransaccion3, + mc.CodigoIva3, + mc.BaseIva4, + mc.PorBaseCorrectora4, + mc.PorIva4, + mc.CuotaIva4, + mc.PorRecargoEquivalencia4, + mc.RecargoEquivalencia4, + mc.CodigoTransaccion4, + mc.CodigoIva4, + mc.Año, + mc.Serie, + mc.Factura, + mc.SuFacturaNo, + mc.FechaFactura, + mc.ImporteFactura, + 'E', + mc.CodigoCuentaFactura, + mc.CifDni, + mc.Nombre, + mc.CodigoRetencion, + mc.BaseRetencion, + mc.PorRetencion, + mc.ImporteRetencion, + mc.SiglaNacion, + mc.EjercicioFactura, + x.FECHA, + mc.Exclusion347, + mc.MantenerAsiento, + mc.Metalico347, + mc.ClaveOperacionFactura, + mc.TipoRectificativa, + mc.FechaFacturaOriginal, + mc.CuotaIvaOriginal, + mc.BaseImponibleOriginal, + mc.ClaseAbonoRectificativas, + mc.RecargoEquivalenciaOriginal, + mc.LibreA1, + mc.IvaDeducible1, + mc.IvaDeducible2, + mc.IvaDeducible3, + mc.IvaDeducible4, + mc.FechaGrabacion, + mc.Intracomunitaria, + mc.moveData + FROM sage.XDiario_movConta_IVA mc + JOIN vn.XDiario x ON x.id = mc.id + JOIN (SELECT x.ASIEN, x.id + FROM vn.XDiario x + JOIN(SELECT DISTINCT(x.ASIEN) ASIEN + FROM (SELECT DISTINCT(ASIEN) + FROM vn.XDiario x + WHERE SUBCTA LIKE '472%' AND + x.enlazadoSage = FALSE AND + x.FECHA >= vDated + ) sub JOIN vn.XDiario x ON x.ASIEN = sub.ASIEN + WHERE x.SUBCTA LIKE '477%' + )sub2 ON sub2.ASIEN = x.ASIEN + WHERE x.CONTRA IS NOT NULL AND x.SUBCTA LIKE '477%' + GROUP BY x.ASIEN + )sub3 ON sub3.ASIEN = x.ASIEN; + + INSERT INTO sage.XDiario_movConta_IVA + (`id`, + `CodigoDivisa`, + `BaseIva1`, + `PorBaseCorrectora1`, + `PorIva1`, + `CuotaIva1`, + `PorRecargoEquivalencia1`, + `RecargoEquivalencia1`, + `CodigoTransaccion1`, + `CodigoIva1`, + `BaseIva2`, + `PorBaseCorrectora2`, + `PorIva2`, + `CuotaIva2`, + `PorRecargoEquivalencia2`, + `RecargoEquivalencia2`, + `CodigoTransaccion2`, + `CodigoIva2`, + `BaseIva3`, + `PorBaseCorrectora3`, + `PorIva3`, + `CuotaIva3`, + `PorRecargoEquivalencia3`, + `RecargoEquivalencia3`, + `CodigoTransaccion3`, + `CodigoIva3`, + `BaseIva4`, + `PorBaseCorrectora4`, + `PorIva4`, + `CuotaIva4`, + `PorRecargoEquivalencia4`, + `RecargoEquivalencia4`, + `CodigoTransaccion4`, + `CodigoIva4`, + `Año`, + `Serie`, + `Factura`, + `SuFacturaNo`, + `FechaFactura`, + `ImporteFactura`, + `TipoFactura`, + `CodigoCuentaFactura`, + `CifDni`, + `Nombre`, + `CodigoRetencion`, + `BaseRetencion`, + `PorRetencion`, + `ImporteRetencion`, + `SiglaNacion`, + `EjercicioFactura`, + `FechaOperacion`, + `Exclusion347`, + `MantenerAsiento`, + `Metalico347`, + `ClaveOperacionFactura`, + `TipoRectificativa`, + `FechaFacturaOriginal`, + `CuotaIvaOriginal`, + `BaseImponibleOriginal`, + `ClaseAbonoRectificativas`, + `RecargoEquivalenciaOriginal`, + `LibreA1`, + `IvaDeducible1`, + `IvaDeducible2`, + `IvaDeducible3`, + `IvaDeducible4`, + `FechaGrabacion`, + `Intracomunitaria`, + `moveData`) + SELECT * + FROM tmp.XDiario_movConta_IVA; + DROP TEMPORARY TABLE tmp.XDiario_movConta_IVA; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21493,35 +21749,35 @@ BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; - DECLARE vVat DOUBLE; - DECLARE vRate DOUBLE; - DECLARE vIs340 DOUBLE; - DECLARE vIs347 DOUBLE; - DECLARE vVatRE DOUBLE; - DECLARE vRateRE DOUBLE; - DECLARE vTransactionCode INT; - DECLARE vCounter INT DEFAULT 0; - DECLARE vInvoiceOutCorrectedFk INT; + DECLARE vVat DOUBLE; + DECLARE vRate DOUBLE; + DECLARE vIs340 DOUBLE; + DECLARE vIs347 DOUBLE; + DECLARE vVatRE DOUBLE; + DECLARE vRateRE DOUBLE; + DECLARE vTransactionCode INT; + DECLARE vCounter INT DEFAULT 0; + DECLARE vInvoiceOutCorrectedFk INT; DECLARE vTaxCode INT; - DECLARE vIsIntracommunity BOOL DEFAULT FALSE; - DECLARE vOperationCode VARCHAR(1); - + DECLARE vIsIntracommunity BOOL DEFAULT FALSE; + DECLARE vOperationCode VARCHAR(1); + -- IVA DECLARE rs CURSOR FOR SELECT oit.taxableBase, oit.vat, - pgc.rate, - pgc.mod340, - pgc.mod347, - pgcRE.rate as rateRE, - oitRE.vat as vatRE, - tc.transactionCode , + pgc.rate, + pgc.mod340, + pgc.mod347, + pgcRE.rate as rateRE, + oitRE.vat as vatRE, + tc.transactionCode , tc.taxCode, - tc.isIntracommunity, - tc.operationcode + tc.isIntracommunity, + tc.operationcode FROM vn.invoiceOutTax oit JOIN vn.pgc ON pgc.code = oit.pgcFk - LEFT JOIN vn.pgcEqu e ON e.vatFk = oit.pgcFk + LEFT JOIN vn.pgcEqu e ON e.vatFk = oit.pgcFk LEFT JOIN vn.pgcEqu eRE ON eRE.equFk = oit.pgcFk LEFT JOIN vn.invoiceOutTax oitRE ON oitRE.invoiceOutFk = oit.invoiceOutFk AND oitRE.pgcFk = e.equFk LEFT JOIN vn.pgc pgcRE ON pgcRE.code = oitRE.pgcFk @@ -21540,64 +21796,64 @@ BEGIN OPEN rs; FETCH rs INTO vBase, vVat, - vRate, - vIs340, - vIs347, - vVatRE, - vRateRE, - vTransactionCode, - vTaxCode, - vIsIntracommunity, - vOperationCode; + vRate, + vIs340, + vIs347, + vVatRE, + vRateRE, + vTransactionCode, + vTaxCode, + vIsIntracommunity, + vOperationCode; WHILE NOT vDone DO - + IF vOperationCode IS NOT NULL THEN UPDATE XDiario_movConta_IVA SET ClaveOperacionFactura = vOperationCode WHERE id = vXDiarioId; - END IF; - + END IF; + SET vCounter = vCounter + 1; CASE vCounter WHEN 1 THEN UPDATE XDiario_movConta_IVA SET BaseIva1 = vBase, PorIva1 = vRate, - CuotaIva1 = vVat, - PorRecargoEquivalencia1 = vVatRE, - RecargoEquivalencia1 = vRateRE, - CodigoTransaccion1 = vTransactionCode, + CuotaIva1 = vVat, + PorRecargoEquivalencia1 = vVatRE, + RecargoEquivalencia1 = vRateRE, + CodigoTransaccion1 = vTransactionCode, CodigoIva1 = vTaxCode WHERE id = vXDiarioId; - WHEN 2 THEN - UPDATE XDiario_movConta_IVA + WHEN 2 THEN + UPDATE XDiario_movConta_IVA SET BaseIva2 = vBase, PorIva2 = vRate, - CuotaIva2 = vVat, - PorRecargoEquivalencia2 = vVatRE, - RecargoEquivalencia2 =vRateRE, - CodigoTransaccion2 = vTransactionCode, + CuotaIva2 = vVat, + PorRecargoEquivalencia2 = vVatRE, + RecargoEquivalencia2 =vRateRE, + CodigoTransaccion2 = vTransactionCode, CodigoIva2 = vTaxCode WHERE id = vXDiarioId; - WHEN 3 THEN + WHEN 3 THEN UPDATE XDiario_movConta_IVA SET BaseIva3 = vBase, PorIva3 = vRate, - CuotaIva3 = vVat, - PorRecargoEquivalencia3 = vVatRE, - RecargoEquivalencia3 = vRateRE, - CodigoTransaccion3 = vTransactionCode, + CuotaIva3 = vVat, + PorRecargoEquivalencia3 = vVatRE, + RecargoEquivalencia3 = vRateRE, + CodigoTransaccion3 = vTransactionCode, CodigoIva3 = vTaxCode WHERE id = vXDiarioId; - WHEN 4 THEN - UPDATE XDiario_movConta_IVA + WHEN 4 THEN + UPDATE XDiario_movConta_IVA SET BaseIva4 = vBase, PorIva4 = vRate, - CuotaIva4 = vVat, - PorRecargoEquivalencia4 = vVatRE, - RecargoEquivalencia4 = vRateRE, - CodigoTransaccion4 = vTransactionCode, + CuotaIva4 = vVat, + PorRecargoEquivalencia4 = vVatRE, + RecargoEquivalencia4 = vRateRE, + CodigoTransaccion4 = vTransactionCode, CodigoIva4 = vTaxCode WHERE id = vXDiarioId; END CASE; @@ -21605,37 +21861,37 @@ BEGIN UPDATE XDiario_movConta_IVA SET Exclusion347 = NOT vIs347 WHERE id = vXDiarioId; - + IF vIsIntracommunity THEN UPDATE XDiario_movConta_IVA SET Intracomunitaria = TRUE WHERE id = vXDiarioId; - END IF; + END IF; - FETCH rs INTO vBase, + FETCH rs INTO vBase, vVat, - vRate, - vIs340, - vIs347, - vVatRE, - vRateRE, - vTransactionCode, - vTaxCode, - vIsIntracommunity, - vOperationCode; + vRate, + vIs340, + vIs347, + vVatRE, + vRateRE, + vTransactionCode, + vTaxCode, + vIsIntracommunity, + vOperationCode; END WHILE; CLOSE rs; -- OTROS CAMPOS RELATIVOS A LAS FACTURAS - UPDATE XDiario_movConta_IVA xmi + UPDATE XDiario_movConta_IVA xmi JOIN vn.invoiceOut io ON io.id = vInvoiceOutFk LEFT JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutFk LEFT JOIN vn.invoiceOut ioc ON ioc.id = ic.correctingFk JOIN vn2008.XDiario x ON x.id = xmi.id JOIN vn.client c ON c.id = io.clientFk - JOIN Naciones n ON n.countryFk = c.countryFk + JOIN Naciones n ON n.countryFk = c.countryFk JOIN vn.invoiceOutSerial ios ON ios.code = io.serial JOIN vn.taxArea ta ON ta.code = ios.taxAreaFk - JOIN (SELECT SERIE + JOIN (SELECT SERIE FROM vn2008.XDiario WHERE ASIEN = (SELECT ASIEN FROM vn2008.XDiario @@ -21658,42 +21914,42 @@ BEGIN xmi.MantenerAsiento = TRUE, xmi.FechaFacturaOriginal = x.FECHA_EX WHERE xmi.id = vXDiarioId; - - -- RECTIFICATIVAS + + -- RECTIFICATIVAS SELECT correctedFk INTO vInvoiceOutCorrectedFk FROM vn.invoiceCorrection WHERE correctingFk = vInvoiceOutFk; - + IF vInvoiceOutCorrectedFk THEN UPDATE XDiario_movConta_IVA xmi JOIN vn.invoiceOut ioc ON ioc.id = vInvoiceOutCorrectedFk JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk - JOIN vn.invoiceOut io ON io.id = vInvoiceOutCorrectedFk + JOIN vn.invoiceOut io ON io.id = vInvoiceOutCorrectedFk JOIN ( SELECT sum(IF(IFNULL(e.vatFk,1),iot.taxableBase,0)) AS Base, sum(IF(IFNULL(e.vatFk,1),iot.vat,0)) AS CuotaIva, - sum(IF(IFNULL(e.vatFk,1),0,iot.vat)) as RE + sum(IF(IFNULL(e.vatFk,1),0,iot.vat)) as RE FROM vn.invoiceOutTax iot LEFT JOIN vn.pgcEqu e ON e.vatFk = iot.pgcFk WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk ) iocTAX - SET xmi.TipoRectificativa = 2, + SET xmi.TipoRectificativa = 2, xmi.ClaseAbonoRectificativas = 1, -- ic.invoiceCorrectionTypeFk no coincide con las opcioens de SAGE * - xmi.FechaFacturaOriginal = io.issued, - xmi.FechaOperacion = io.issued, + xmi.FechaFacturaOriginal = io.issued, + xmi.FechaOperacion = io.issued, xmi.BaseImponibleOriginal = iocTAX.Base, xmi.CuotaIvaOriginal = iocTAX.CuotaIva, xmi.RecargoEquivalenciaOriginal = RE, - xmi.ClaveOperacionFactura = 'D' + xmi.ClaveOperacionFactura = 'D' WHERE xmi.id = vXDiarioId; /* - Envases y embalajes / descuentos y bonificaciones / eror fundado - Concurso de acreedores - Creditos incobrables - resto de tectificativas - Restificativas de facturas simplificadas - */ + Envases y embalajes / descuentos y bonificaciones / eror fundado + Concurso de acreedores + Creditos incobrables + resto de tectificativas + Restificativas de facturas simplificadas + */ END IF; END ;; DELIMITER ; @@ -21716,9 +21972,9 @@ BEGIN DECLARE done BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; - DECLARE vXDiarioFk INT; + DECLARE vXDiarioFk INT; DECLARE vDated DATE; - + DECLARE rs CURSOR FOR SELECT io.id invoiceOutFk, x.XDiarioFk FROM vn.invoiceOut io @@ -21738,7 +21994,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; SELECT CONCAT(YEAR(CURDATE()), "-01-01") INTO vDated; - OPEN rs; + OPEN rs; FETCH rs INTO vInvoiceFk, vXDiarioFk; WHILE NOT done DO CALL XDiario_movConta_IVA_InvoiceOutAdd(vInvoiceFk, vXDiarioFk); @@ -23458,7 +23714,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `dayEnd`(vDated DATE) RETURNS datetime +CREATE DEFINER=`root`@`%` FUNCTION `dayend`(vDated DATE) RETURNS datetime NO SQL DETERMINISTIC BEGIN @@ -23613,7 +23869,7 @@ CREATE DEFINER=`root`@`%` FUNCTION `midnight`() RETURNS datetime READS SQL DATA BEGIN - RETURN TIMESTAMPADD(SECOND, 24 * 60 * 60 - 1, CURDATE()); + RETURN TIMESTAMP(CURDATE(), '23:59:59'); END ;; DELIMITER ; @@ -24933,6 +25189,8 @@ CREATE TABLE `agencyTerm` ( `packagePrice` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'precio extra por bulto', `routePrice` decimal(10,2) DEFAULT NULL COMMENT 'precio fijo por ruta', `minimumKm` int(11) NOT NULL DEFAULT '0', + `minimumM3` decimal(10,0) DEFAULT NULL, + `m3Price` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`agencyFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25115,42 +25373,6 @@ BEGIN SET NEW.year= year(CURDATE()); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_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 `awb_ai` AFTER INSERT ON `awb` FOR EACH ROW -BEGIN - - DECLARE invoiceInFk INT; - - -- Eliminar cuando funcione el sistema DUA - INSERT INTO invoiceIn(supplierFk,issued,companyFk) - VALUES(NEW.transitoryFk,CURDATE(),442); - - SELECT last_insert_id() INTO invoiceInFk; -/* - INSERT INTO awb_recibida(awb_id,recibida_id) - VALUES(NEW.id,invoiceInFk); - */ - -- Sistema DUA - INSERT INTO vn.dua(awbFk) - VALUES(NEW.id); - - INSERT INTO vn.duaInvoiceIn(duaFk, invoiceInFk) - VALUES(LAST_INSERT_ID(), invoiceInFk); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -26118,6 +26340,7 @@ DROP TABLE IF EXISTS `claimReason`; CREATE TABLE `claimReason` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `isTired` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Motivos de las fallos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26214,12 +26437,12 @@ CREATE TABLE `client` ( `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)', + `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)', + `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, @@ -26234,18 +26457,18 @@ CREATE TABLE `client` ( `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)', + `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 sepaobsoleta (comprobar)', `hasSepaVnl` tinyint(1) DEFAULT '0', - `coreFth` tinyint(1) DEFAULT '0' COMMENT 'obsoleta (comprobar)', + `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)', + `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)', + `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', @@ -26272,7 +26495,7 @@ CREATE TABLE `client` ( KEY `Telefono` (`phone`), KEY `movil` (`mobile`), KEY `tipos_de_cliente_idx` (`clientTypeFk`), - KEY `codpos` (`codposOLD`,`postcode`), + KEY `codpos` (`codposOLD__`,`postcode`), KEY `fk_Clientes_entity_idx` (`bankEntityFk`), KEY `typeFk` (`typeFk`), KEY `client_taxTypeSageFk_idx` (`taxTypeSageFk`), @@ -27005,6 +27228,26 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `collectionSmartTag` +-- + +DROP TABLE IF EXISTS `collectionSmartTag`; +/*!50001 DROP VIEW IF EXISTS `collectionSmartTag`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `collectionSmartTag` ( + `code` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `level` tinyint NOT NULL, + `wagon` tinyint NOT NULL, + `shelvingFk` tinyint NOT NULL, + `collectionFk` tinyint NOT NULL, + `agencyFk` tinyint NOT NULL, + `clientFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `collectionVolumetry` -- @@ -27018,18 +27261,21 @@ CREATE TABLE `collectionVolumetry` ( `lines` int(10) unsigned NOT NULL DEFAULT '1', `liters` int(10) unsigned NOT NULL DEFAULT '0', `height` int(10) unsigned NOT NULL DEFAULT '20', - PRIMARY KEY (`id`) + `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'H', + PRIMARY KEY (`id`), + KEY `collectionVolumetry_FK` (`itemPackingTypeFk`), + CONSTRAINT `collectionVolumetry_FK` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `collectionVolumetry_Paloma` +-- Table structure for table `collectionVolumetry_Paloma__` -- -DROP TABLE IF EXISTS `collectionVolumetry_Paloma`; +DROP TABLE IF EXISTS `collectionVolumetry_Paloma__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `collectionVolumetry_Paloma` ( +CREATE TABLE `collectionVolumetry_Paloma__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `level` int(10) unsigned NOT NULL DEFAULT '0', `lines` int(10) unsigned NOT NULL DEFAULT '1', @@ -27130,6 +27376,7 @@ CREATE TABLE `component` ( `tax` double DEFAULT NULL, `isRenewable` tinyint(2) NOT NULL DEFAULT '1', `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isRequired` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Son componentes imprescindibles en toda venta', PRIMARY KEY (`id`), KEY `series_componentes_idx` (`typeFk`), KEY `comp` (`classRate`), @@ -27480,6 +27727,21 @@ CREATE TABLE `conveyorType` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `corridor` +-- + +DROP TABLE IF EXISTS `corridor`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `corridor` ( + `code` varchar(1) COLLATE utf8_unicode_ci NOT NULL COMMENT 'letra que da nombre al pasillo', + `isAscendent` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'TRUE cuando se prepara de menor a mayor, FALSE cuando es a la inversa', + `prepOrder` int(10) unsigned NOT NULL COMMENT 'orden de preparacion de los pasillos', + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='establece el orden y sentido de preparacion de los pasillos del parking'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `country` -- @@ -28179,7 +28441,7 @@ CREATE TABLE `dms` ( `hasFile` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '1', + `warehouseFk` smallint(5) unsigned NOT NULL DEFAULT '60', PRIMARY KEY (`id`), UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), KEY `trabajador_id` (`workerFk`), @@ -28202,11 +28464,11 @@ CREATE TABLE `dms` ( DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`dms_beforeInsert` BEFORE INSERT ON `vn`.`dms` FOR EACH ROW BEGIN - DECLARE vHardCopyNumber INT; - DECLARE vDmsTypeCode INT; - - IF NEW.warehouseFk = 44 THEN - SET NEW.warehouseFk = 1; + DECLARE vHardCopyNumber INT; + DECLARE vDmsTypeCode INT; + + IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN + CALL util.throw('this warehouse has not dms'); END IF; IF NEW.hasFile THEN @@ -28214,7 +28476,7 @@ BEGIN FROM dms WHERE companyFk = NEW.companyFk AND warehouseFk = NEW.warehouseFk ; - + SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1) ; END IF; @@ -28241,15 +28503,21 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`dms_beforeUpdate` BEFORE UPDATE ON `vn`.`dms` FOR EACH ROW BEGIN DECLARE vHardCopyNumber INT; + IF (NEW.hasFile <> 0) AND (OLD.hasFile = 0) AND (NEW.hardCopyNumber IS NULL) THEN - + + IF (SELECT NOT hasDms FROM warehouse WHERE id = NEW.warehouseFk) THEN + SET NEW.warehouseFk = (SELECT id FROM warehouse WHERE name = 'Algemesi'); + END IF; + SELECT 1 + MAX(hardCopyNumber) INTO vHardCopyNumber FROM dms WHERE companyFk = NEW.companyFk AND warehouseFk = NEW.warehouseFk; - + SET NEW.hardCopyNumber = IFNULL(vHardCopyNumber,1); END IF; + IF ((NEW.hardCopyNumber = 0) OR NEW.hardCopyNumber IS NULL) AND (OLD.hardCopyNumber <> 0) THEN SET NEW.hasFile = 0; @@ -29119,7 +29387,7 @@ CREATE TABLE `expedition` ( `counter` smallint(5) unsigned NOT NULL, `checked` tinyint(4) NOT NULL DEFAULT '0', `workerFk` int(11) DEFAULT NULL, - `externalId` bigint(25) DEFAULT NULL, + `externalId` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `packagingFk` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), @@ -29326,7 +29594,8 @@ SET character_set_client = utf8; `eti` tinyint NOT NULL, `palletFk` tinyint NOT NULL, `isMatch` tinyint NOT NULL, - `warehouseFk` tinyint NOT NULL + `warehouseFk` tinyint NOT NULL, + `nombreDia` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -29343,7 +29612,8 @@ SET character_set_client = utf8; `tickets` tinyint NOT NULL, `expeditions` tinyint NOT NULL, `scanned` tinyint NOT NULL, - `lastPacked` tinyint NOT NULL + `lastPacked` tinyint NOT NULL, + `created` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -29360,7 +29630,8 @@ SET character_set_client = utf8; `ticket` tinyint NOT NULL, `code` tinyint NOT NULL, `almacen` tinyint NOT NULL, - `updated` tinyint NOT NULL + `updated` tinyint NOT NULL, + `parkingCode` tinyint NOT NULL ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; @@ -29429,6 +29700,31 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `expeditionSticker` +-- + +DROP TABLE IF EXISTS `expeditionSticker`; +/*!50001 DROP VIEW IF EXISTS `expeditionSticker`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `expeditionSticker` ( + `expeditionFk` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `addressFk` tinyint NOT NULL, + `clientFk` tinyint NOT NULL, + `street` tinyint NOT NULL, + `postalCode` tinyint NOT NULL, + `city` tinyint NOT NULL, + `nickname` tinyint NOT NULL, + `routeFk` tinyint NOT NULL, + `beachFk` tinyint NOT NULL, + `zona` tinyint NOT NULL, + `province` tinyint NOT NULL, + `phone` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `expeditionTimeExpended` -- @@ -29874,6 +30170,7 @@ CREATE TABLE `ink` ( `isCargex` tinyint(4) NOT NULL DEFAULT '0', `dutchCode` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `hex` varchar(6) COLLATE utf8_unicode_ci DEFAULT NULL, + `isRealColor` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `dutchCode_UNIQUE` (`dutchCode`), CONSTRAINT `ink_fk1` FOREIGN KEY (`dutchCode`) REFERENCES `edi`.`feature` (`feature_value`) ON DELETE SET NULL ON UPDATE CASCADE @@ -30064,6 +30361,7 @@ CREATE TABLE `invoiceIn` ( `bookEntried` date DEFAULT NULL COMMENT 'Fecha Asiento', `isVatDeductible` tinyint(1) NOT NULL DEFAULT '1', `withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE', + `expenceFkDeductible` varchar(10) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`), KEY `proveedor_id` (`supplierFk`), KEY `empresa_id` (`companyFk`), @@ -30077,6 +30375,8 @@ CREATE TABLE `invoiceIn` ( KEY `recibida_ibfk_6` (`cplusRectificationTypeFk`), KEY `recibida_ibfk_7` (`cplusTrascendency472Fk`), KEY `invoiceIn_withholdingFk_idx` (`withholdingSageFk`), + KEY `invoiceIn_expenceFkDeductible` (`expenceFkDeductible`), + CONSTRAINT `invoiceIn_expenceFkDeductible` FOREIGN KEY (`expenceFkDeductible`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceIn_ibfk_3` FOREIGN KEY (`cplusSubjectOpFk`) REFERENCES `cplusSubjectOp` (`id`) ON UPDATE CASCADE, @@ -30097,53 +30397,58 @@ CREATE TABLE `invoiceIn` ( /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `invoiceIn_bi` BEFORE INSERT ON `invoiceIn` FOR EACH ROW BEGIN - DECLARE vSerie CHAR(1) DEFAULT 'R'; - DECLARE vNumReceived INT; - DECLARE vIssuingCountry, vhostCountry INT; - DECLARE vActive TINYINT; - DECLARE vWithholdingSageFk INT; - - SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier - WHERE id = NEW.supplierFk; - - SET NEW.withholdingSageFk = vWithholdingSageFk; - - SELECT countryFk, isActive INTO vIssuingCountry, vActive - FROM vn.supplier - WHERE id = NEW.supplierFk; - - SELECT countryFk INTO vhostCountry - FROM vn.supplier - WHERE id = NEW.companyFk; - - IF vActive = 0 THEN - CALL util.throw('INACTIVE_PROVIDER'); - END IF; - - IF (SELECT COUNT(*) FROM vn.invoiceIn WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(CURDATE())) THEN - CALL util.throw('reference duplicated'); - END IF; - - SELECT CASE WHEN (SELECT account FROM vn.supplier where id = NEW.supplierFk) LIKE '___3______' THEN 'C' - WHEN (SELECT vIssuingCountry=vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry - where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'R' - WHEN (SELECT vIssuingCountry <> vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry - where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'E' - WHEN (SELECT vIssuingCountry<>vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry - where NOT p1.CEE < 2 AND not p1.id = 1) = 1 THEN 'W' - END INTO vSerie; - - SET NEW.serial = IFNULL(vSerie,'R'); + DECLARE vSerie CHAR(1) DEFAULT 'R'; + DECLARE vNumReceived INT; + DECLARE vIssuingCountry, vhostCountry INT; + DECLARE vActive TINYINT; + DECLARE vWithholdingSageFk INT; - IF vSerie LIKE 'W' THEN - SELECT IFNULL(MAX(serialNumber) + 1,1) INTO vNumReceived - FROM invoiceIn - WHERE `serial` LIKE NEW.serial AND - YEAR(issued) = YEAR(NEW.issued) AND - companyFk = NEW.companyFk; - SET NEW.serialNumber = vNumReceived; - END IF; + SELECT withholdingSageFk INTO vWithholdingSageFk + FROM vn.supplier + WHERE id = NEW.supplierFk; + + SET NEW.withholdingSageFk = vWithholdingSageFk; + + SELECT countryFk, isActive INTO vIssuingCountry, vActive + FROM vn.supplier + WHERE id = NEW.supplierFk; + + SELECT countryFk INTO vhostCountry + FROM vn.supplier + WHERE id = NEW.companyFk; + + IF vActive = 0 THEN + CALL util.throw('INACTIVE_PROVIDER'); + END IF; + + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk + AND YEAR(issued) = YEAR(NEW.issued) + AND id = NEW.id + ) THEN + CALL util.throw('reference duplicated'); + END IF; + + SELECT CASE WHEN (SELECT account FROM vn.supplier where id = NEW.supplierFk) LIKE '___3______' THEN 'C' + WHEN (SELECT vIssuingCountry=vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry + where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'R' + WHEN (SELECT vIssuingCountry <> vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry + where p1.CEE < 2 and p2.CEE < 2) = 1 THEN 'E' + WHEN (SELECT vIssuingCountry<>vhostCountry from vn.country p1 join vn.country p2 ON p2.id = vhostCountry AND p1.id = vIssuingCountry + where NOT p1.CEE < 2 AND not p1.id = 1) = 1 THEN 'W' + END INTO vSerie; + + SET NEW.serial = IFNULL(vSerie,'R'); + + IF vSerie LIKE 'W' THEN + SELECT IFNULL(MAX(serialNumber) + 1,1) INTO vNumReceived + FROM invoiceIn + WHERE `serial` LIKE NEW.serial AND + YEAR(issued) = YEAR(NEW.issued) AND + companyFk = NEW.companyFk; + SET NEW.serialNumber = vNumReceived; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -30163,13 +30468,23 @@ DELIMITER ;; BEGIN DECLARE vWithholdingSageFk INT; - + + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk + AND YEAR(issued) = YEAR(NEW.issued) + AND id <> NEW.id + ) THEN + CALL util.throw('reference duplicated'); + END IF; + IF NEW.supplierFk != OLD.supplierFk THEN - SELECT withholdingSageFk INTO vWithholdingSageFk + SELECT withholdingSageFk INTO vWithholdingSageFk FROM vn.supplier WHERE id = NEW.supplierFk; SET NEW.withholdingSageFk = vWithholdingSageFk; - END IF; + END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -30389,6 +30704,39 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `invoiceInSage` +-- + +DROP TABLE IF EXISTS `invoiceInSage`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `invoiceInSage` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `taxClassFk` varchar(1) COLLATE utf8_unicode_ci NOT NULL, + `invoiceInSerialFk` varchar(2) COLLATE utf8_unicode_ci NOT NULL, + `taxTypeSageFk` smallint(6) NOT NULL, + `transactionTypeSageFk` tinyint(4) NOT NULL, + `isService` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para diferenciar producto de servicio', + `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `withholdingSageFk` smallint(6) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `invoiceInSafe_unique` (`taxClassFk`,`invoiceInSerialFk`,`isService`,`withholdingSageFk`), + KEY `invoiceInSage_expenceFk` (`expenceFk`), + KEY `invoiceInSage_withholdingSageFk` (`withholdingSageFk`), + KEY `invoiceInSage_taxClassFk` (`taxClassFk`), + KEY `invoiceInSage_invoiceInSerialFk` (`invoiceInSerialFk`), + KEY `invoiceInSage_taxTypeSageFk` (`taxTypeSageFk`), + KEY `invoiceInSage_transactionTypeSageFk` (`transactionTypeSageFk`), + CONSTRAINT `invoiceInSage_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInSage_invoiceInSerialFk` FOREIGN KEY (`invoiceInSerialFk`) REFERENCES `invoiceInSerial` (`code`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInSage_taxClassFk` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`code`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInSage_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInSage_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInSage_withholdingSageFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciones de entrelas series de facturas recibidas y sus tipo de IVA con código Iva y codigo de Transación en Sage. Para precontabilizadar facturas recibidas'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `invoiceInSerial` -- @@ -30419,7 +30767,7 @@ DROP TABLE IF EXISTS `invoiceInTax`; CREATE TABLE `invoiceInTax` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `invoiceInFk` mediumint(8) unsigned NOT NULL, - `taxCodeFk` int(10) unsigned NOT NULL, + `taxCodeFk` int(10) DEFAULT NULL, `taxableBase` decimal(10,2) NOT NULL, `expenceFk` varchar(10) CHARACTER SET utf8 NOT NULL, `foreignValue` decimal(10,2) DEFAULT NULL, @@ -30432,40 +30780,12 @@ CREATE TABLE `invoiceInTax` ( KEY `recibida_iva_gastos_id` (`expenceFk`), KEY `recibida_iva_taxTypeSageFk` (`taxTypeSageFk`), KEY `invoiceInTax_transactionTypeSageFk_idx` (`transactionTypeSageFk`), - CONSTRAINT `invoiceInTax_ibfk_2` FOREIGN KEY (`taxCodeFk`) REFERENCES `taxCode` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `invoiceInTax_ibfk_5` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInTax_transactionTypeSageFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE, CONSTRAINT `recibida_iva_gastos_id` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `recibida_iva_taxTypeSageFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT 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`.`invoiceInTax_beforeInsert` BEFORE INSERT ON `invoiceInTax` FOR EACH ROW -BEGIN - DECLARE vTaxTypeSageFk INT; - DECLARE vTransactionTypeSageFk INT; - - SELECT taxTypeSageFk, transactionTypeSageFk INTO vTaxTypeSageFk,vTransactionTypeSageFk - FROM vn.supplier s - JOIN vn.invoiceIn i On i.supplierFk = s.id - WHERE i.id = NEW.invoiceInFk; - - SET NEW.taxTypeSageFk = vTaxTypeSageFk; - SET NEW.transactionTypeSageFk = vTransactionTypeSageFk; -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 `invoiceInTaxBookingAccount` @@ -30535,8 +30855,8 @@ DROP TABLE IF EXISTS `invoiceOut`; /*!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, + `ref` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `serial` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, `issued` date DEFAULT NULL, `amount` decimal(12,2) DEFAULT '0.00', `dued` datetime DEFAULT NULL, @@ -30573,10 +30893,12 @@ CREATE TABLE `invoiceOut` ( KEY `Facturas_ibfk_4_idx` (`cplusTaxBreakFk`), KEY `Facturas_ibfk_5_idx` (`cplusTrascendency477Fk`), KEY `Facturas_idx_Vencimiento` (`dued`), + KEY `invoiceOut_serial` (`serial`), 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 `invoiceOut_serial` FOREIGN KEY (`serial`) REFERENCES `invoiceOutSerial` (`code`), 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=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -30717,6 +31039,7 @@ CREATE TABLE `invoiceOutSerial` ( `isCEE` tinyint(1) NOT NULL DEFAULT '0', `cplusInvoiceType477Fk` int(10) unsigned DEFAULT '1', `footNotes` longtext COLLATE utf8_unicode_ci, + `isRefEditable` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`code`), KEY `taxAreaFk_idx` (`taxAreaFk`), CONSTRAINT `invoiceOutSeriaTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE @@ -30763,7 +31086,7 @@ CREATE TABLE `item` ( `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', + `family` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT 'VT', `box` tinyint(1) NOT NULL DEFAULT '0', `category` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `originFk` tinyint(2) unsigned NOT NULL, @@ -30813,6 +31136,7 @@ CREATE TABLE `item` ( `stars` int(11) DEFAULT NULL, `stemMultiplier` double NOT NULL DEFAULT '1' COMMENT 'este valor multiplica las unidades y divide los precios en el procedimiento edi.ekt_load', `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `packingOut` int(11) DEFAULT NULL COMMENT 'cantidad que cabe en una caja de verdnatura', PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -30828,7 +31152,9 @@ CREATE TABLE `item` ( KEY `item_id10` (`embalageCode`), KEY `item_id11` (`numberOfItemsPerCask`), KEY `item_id12` (`quality`), + KEY `item_family` (`family`), CONSTRAINT `item_expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE, + CONSTRAINT `item_family` FOREIGN KEY (`family`) REFERENCES `itemFamily` (`code`) 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, @@ -30937,6 +31263,9 @@ BEGIN IF NEW.density = 0 THEN CALL util.throw('error densidad = 0'); END IF; + IF (SELECT NEW.compression < minCompressionRate FROM vn.volumeConfig vc) AND NEW.compression < OLD.compression THEN + CALL util.throw('compression too low'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31256,6 +31585,20 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemFamily` +-- + +DROP TABLE IF EXISTS `itemFamily`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemFamily` ( + `code` varchar(3) CHARACTER SET utf8 NOT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemImageQueue` -- @@ -31276,6 +31619,20 @@ CREATE TABLE `itemImageQueue` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Cola para añadir las imagenes al campo vn.item.image a partir de una url'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `itemInk` +-- + +DROP TABLE IF EXISTS `itemInk`; +/*!50001 DROP VIEW IF EXISTS `itemInk`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `itemInk` ( + `longName` tinyint NOT NULL, + `inkFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `itemLabel` -- @@ -32246,7 +32603,7 @@ CREATE TABLE `itemType` ( `target` double NOT NULL DEFAULT '0.15', `topMargin` double NOT NULL DEFAULT '0.3', `profit` double NOT NULL DEFAULT '0.02', - `isFV` tinyint(3) DEFAULT '1', + `isFV__` tinyint(3) DEFAULT '1', `density` double NOT NULL DEFAULT '167' COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', `promo` double NOT NULL DEFAULT '0', `isBox__` tinyint(4) NOT NULL DEFAULT '0', @@ -32405,6 +32762,20 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `labelReport` +-- + +DROP TABLE IF EXISTS `labelReport`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `labelReport` ( + `id` tinyint(3) unsigned NOT NULL, + `name` 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 */; + -- -- Table structure for table `labourTree` -- @@ -32483,6 +32854,108 @@ CREATE TABLE `lungSize` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `machine` +-- + +DROP TABLE IF EXISTS `machine`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `machine` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `plate` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `serialNumber` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL, + `maker` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `model` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `purchased` date DEFAULT NULL, + `warehouseFk` int(11) DEFAULT NULL, + `departmentFk` int(11) DEFAULT NULL, + `type` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `use` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `productionYear` int(11) DEFAULT NULL, + `photo` blob, + `workerFk` int(11) DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `ppeFk` int(11) DEFAULT NULL, + `supplierFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `plate` (`plate`), + UNIQUE KEY `serialNumber` (`serialNumber`), + KEY `machine_FK` (`ppeFk`), + KEY `machine_FK_1` (`workerFk`), + KEY `machine_FK_2` (`supplierFk`), + CONSTRAINT `machine_FK` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `machine_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `machine_FK_2` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Maquinaria industrial, vehículos y demás elementos amortizables'; +/*!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 machine_BI +BEFORE INSERT +ON machine FOR EACH ROW +BEGIN + + SET NEW.workerFk = vn.getUser(); + +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 `machineDetail` +-- + +DROP TABLE IF EXISTS `machineDetail`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `machineDetail` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `machineFk` int(11) NOT NULL, + `dated` date NOT NULL, + `action` varchar(100) COLLATE utf8_unicode_ci NOT NULL, + `value` decimal(10,2) DEFAULT NULL, + `workerFk` int(11) NOT NULL, + `dmsFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `machineDetail_FK` (`machineFk`), + KEY `machineDetail_FK_1` (`workerFk`), + KEY `machineDetail_FK_2` (`dmsFk`), + CONSTRAINT `machineDetail_FK` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `machineDetail_FK_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, + CONSTRAINT `machineDetail_FK_2` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `machineDms` +-- + +DROP TABLE IF EXISTS `machineDms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `machineDms` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `machineFk` int(11) NOT NULL, + `dmsFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `machineDms_UN` (`machineFk`,`dmsFk`), + KEY `machineDms_FK` (`dmsFk`), + CONSTRAINT `machineDms_FK` FOREIGN KEY (`dmsFk`) REFERENCES `dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `machineDms_FK_1` FOREIGN KEY (`machineFk`) REFERENCES `machine` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `mail` -- @@ -32858,6 +33331,20 @@ CREATE TABLE `observationType` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `occupationCode` +-- + +DROP TABLE IF EXISTS `occupationCode`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `occupationCode` ( + `code` varchar(1) CHARACTER SET utf8 NOT NULL, + `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Código de ocupación de la seguridad social'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `orderTicket` -- @@ -33036,8 +33523,9 @@ DROP TABLE IF EXISTS `packagingConfig`; CREATE TABLE `packagingConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `upperGap` int(11) NOT NULL, + `previousPreparationMinimumSize` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Altura mínima para preparar pedidos en preparacion previa'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33805,7 +34293,7 @@ CREATE TABLE `printServerQueue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `printerFk` tinyint(3) unsigned DEFAULT NULL, `priorityFk` tinyint(3) unsigned DEFAULT NULL, - `reportFk` tinyint(3) unsigned DEFAULT '0', + `labelReportFk` tinyint(3) unsigned DEFAULT '0', `statusFk` tinyint(3) unsigned DEFAULT '1', `started` datetime DEFAULT NULL, `finished` datetime DEFAULT NULL, @@ -33815,11 +34303,11 @@ CREATE TABLE `printServerQueue` ( `param3` text COLLATE utf8_unicode_ci, `error` text COLLATE utf8_unicode_ci, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `reportFk` tinyint(3) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`reportFk`,`statusFk`,`param1`,`workerFk`,`param2`), + UNIQUE KEY `Id_Impresora_2` (`printerFk`,`priorityFk`,`labelReportFk`,`statusFk`,`param1`,`workerFk`,`param2`), KEY `Id_estado` (`statusFk`), KEY `Id_Impresora` (`printerFk`), - KEY `Id_Informe` (`reportFk`), KEY `Id_Prioridad` (`priorityFk`), KEY `Id_Trabajador` (`workerFk`), CONSTRAINT `printServerQueue_ibfk_3` FOREIGN KEY (`priorityFk`) REFERENCES `queuePriority` (`id`) ON UPDATE CASCADE, @@ -34636,6 +35124,14 @@ CREATE TABLE `routeConfig` ( `load5m3` decimal(10,4) DEFAULT NULL, `load6m3` decimal(10,4) DEFAULT NULL, `rateHoliday` decimal(5,2) DEFAULT NULL, + `plusCategory1` decimal(5,2) DEFAULT NULL, + `plusCategory2` decimal(5,2) DEFAULT NULL, + `maxSalaryCategory1` decimal(6,2) DEFAULT NULL, + `maxSalaryCategory2` decimal(6,2) DEFAULT NULL, + `distributionM3Category1` decimal(5,2) DEFAULT NULL, + `distributionM3Category2` decimal(5,2) DEFAULT NULL, + `plusCategory1Concept` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `plusCategory2Concept` varchar(45) 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 */; @@ -34763,30 +35259,31 @@ CREATE TABLE `routeUserPercentage` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `routesMonitor` +-- Table structure for table `routesMonitor` -- DROP TABLE IF EXISTS `routesMonitor`; -/*!50001 DROP VIEW IF EXISTS `routesMonitor`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `routesMonitor` ( - `routeFk` tinyint NOT NULL, - `name` tinyint NOT NULL, - `beachFk` tinyint NOT NULL, - `ticketPacked` tinyint NOT NULL, - `ticketFree` tinyint NOT NULL, - `ticketProduction` tinyint NOT NULL, - `packages` tinyint NOT NULL, - `note` tinyint NOT NULL, - `dated` tinyint NOT NULL, - `dockFk` tinyint NOT NULL, - `m3` tinyint NOT NULL, - `priority` tinyint NOT NULL, - `etd` tinyint NOT NULL, - `expeditionTruckFk` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `routesMonitor` ( + `routeFk` int(10) unsigned NOT NULL, + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `beachFk` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `ticketPacked` int(11) DEFAULT NULL, + `ticketFree` int(11) DEFAULT NULL, + `ticketProduction` int(11) DEFAULT NULL, + `packages` int(11) DEFAULT NULL, + `note` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `dated` date DEFAULT NULL, + `dockFk` int(11) DEFAULT NULL, + `m3` decimal(10,1) DEFAULT NULL, + `priority` int(11) NOT NULL DEFAULT '0', + `etd` time DEFAULT NULL, + `expeditionTruckFk` int(11) DEFAULT NULL, + `m3boxes` decimal(10,1) DEFAULT NULL, + PRIMARY KEY (`routeFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `sale` @@ -34820,16 +35317,22 @@ CREATE TABLE `sale` ( /*!50003 SET @saved_cs_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' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `sale_afterInsert` - AFTER INSERT ON `sale` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER sale_afterInsert + AFTER INSERT + ON sale FOR EACH ROW -BEGIN +BEGIN + + IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN + CALL util.throw('Cannot insert a service item into a ticket'); + END IF; + CALL stock.log_add('sale', NEW.id, NULL); CALL ticket_requestRecalc(NEW.ticketFk); @@ -34857,12 +35360,17 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `sale_beforeUpdate` - BEFORE UPDATE ON `sale` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER sale_beforeUpdate + BEFORE UPDATE + ON sale FOR EACH ROW BEGIN + + IF (SELECT COUNT(*) from item i WHERE id = NEW.itemFk AND family = 'SER') THEN + CALL util.throw('Cannot insert a service item into a ticket'); + END IF; IF NEW.discount > 100 THEN SET NEW.discount = 0; @@ -34970,9 +35478,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 ;; @@ -35008,7 +35516,7 @@ BEGIN AND (c.itemPackingTypeFk = i.itemPackingTypeFk OR ISNULL(c.itemPackingTypeFk)) SET c.saleTotalCount = c.saleTotalCount - 1, - c.salePickedCount = c.salePickedCount - 1; + c.salePickedCount = c.salePickedCount - ABS(OLD.isPicked); END IF; END */;; @@ -35059,6 +35567,30 @@ 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 SET @saved_cs_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 saleBuy_AI +AFTER INSERT +ON saleBuy FOR EACH ROW +BEGIN + + UPDATE vn.sale s + SET s.concept = CONCAT(s.concept, ' Lote: ', NEW.buyFk) + WHERE s.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 */ ; -- -- Table structure for table `saleChecked` @@ -35112,6 +35644,26 @@ CREATE TABLE `saleComponent` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `saleCost` +-- + +DROP TABLE IF EXISTS `saleCost`; +/*!50001 DROP VIEW IF EXISTS `saleCost`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `saleCost` ( + `itemFk` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `concept` tinyint NOT NULL, + `quantity` tinyint NOT NULL, + `discount` tinyint NOT NULL, + `price` tinyint NOT NULL, + `component` tinyint NOT NULL, + `coste` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `saleFreight__` -- @@ -35271,6 +35823,7 @@ CREATE TABLE `saleTracking` ( KEY `saleTracking_idx5` (`created`), KEY `saleTracking_fk2_idx` (`actionFk`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, + CONSTRAINT `saleTracking_FK` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `saleTracking_fk2` FOREIGN KEY (`actionFk`) REFERENCES `vncontrol`.`accion` (`accion_id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35342,6 +35895,7 @@ SET character_set_client = utf8; `client` tinyint NOT NULL, `clientTypeFk` tinyint NOT NULL, `buyer` tinyint NOT NULL, + `itemTypeFk` tinyint NOT NULL, `family` tinyint NOT NULL, `itemFk` tinyint NOT NULL, `concept` tinyint NOT NULL, @@ -35497,15 +36051,19 @@ CREATE TABLE `sector` ( `path` int(11) DEFAULT NULL, `isPreviousPrepared` tinyint(1) NOT NULL DEFAULT '0', `isPackagingArea` tinyint(1) NOT NULL DEFAULT '0', - `labelReport` int(11) DEFAULT NULL, + `labelReportFk` tinyint(3) unsigned DEFAULT NULL, `sonFk` int(11) DEFAULT NULL, `isMain` tinyint(1) NOT NULL DEFAULT '0', `itemPackingTypeFk` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, + `labelReport` tinyint(3) DEFAULT NULL, + `printerFk` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`,`warehouseFk`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), - CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `sector_labelReport` (`labelReportFk`), + CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `sector_labelReport` FOREIGN KEY (`labelReportFk`) REFERENCES `labelReport` (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35794,6 +36352,25 @@ CREATE TABLE `sinisterDetail` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `smartTag` +-- + +DROP TABLE IF EXISTS `smartTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `smartTag` ( + `code` varchar(12) CHARACTER SET utf8 NOT NULL, + `shelvingFk` varchar(10) CHARACTER SET utf8 DEFAULT NULL, + `level` int(11) DEFAULT NULL, + `ticketFk` int(11) DEFAULT NULL, + KEY `ticket_fk` (`ticketFk`), + KEY `smartTag_shelving_fk` (`shelvingFk`), + CONSTRAINT `smartTag_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE, + CONSTRAINT `smartTag_ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticketCollection` (`ticketFk`) 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 `sms` -- @@ -36194,6 +36771,7 @@ CREATE TABLE `supplierAccount` ( `bicSufix` varchar(3) CHARACTER SET utf8 NOT NULL DEFAULT '', `bankEntityFk` int(10) DEFAULT NULL, `bankFk` int(11) DEFAULT NULL COMMENT 'obsoleta(comprobar)', + `beneficiary` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), @@ -36490,7 +37068,8 @@ 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`) + PRIMARY KEY (`id`), + UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36771,9 +37350,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 ;; @@ -36802,7 +37381,16 @@ BEGIN `body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ', NEW.id); END IF; - + + IF !(NEW.addressFk <=> OLD.addressFk) THEN + DELETE FROM ticketObservation + WHERE ticketFk = NEW.id; + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT NEW.id, ao.observationTypeFk, ao.description + FROM addressObservation ao + WHERE ao.addressFk = NEW.addressFk; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36846,9 +37434,11 @@ CREATE TABLE `ticketCollection` ( `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `level` int(11) DEFAULT NULL, `wagon` int(11) NOT NULL DEFAULT '0', + `smartTagFk` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `ticketCollection_fk1_idx` (`collectionFk`), KEY `ticketCollection_fk2_idx` (`ticketFk`), + KEY `ticketCollection_smartTagFk_IDX` (`smartTagFk`) USING BTREE, CONSTRAINT `ticketCollection_fk1` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketCollection_fk2` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -37086,6 +37676,34 @@ CREATE TABLE `ticketLog` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `ticketMRW` +-- + +DROP TABLE IF EXISTS `ticketMRW`; +/*!50001 DROP VIEW IF EXISTS `ticketMRW`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ticketMRW` ( + `id_Agencia` tinyint NOT NULL, + `empresa_id` tinyint NOT NULL, + `Consignatario` tinyint NOT NULL, + `DOMICILIO` tinyint NOT NULL, + `POBLACION` tinyint NOT NULL, + `CODPOSTAL` tinyint NOT NULL, + `telefono` tinyint NOT NULL, + `movil` tinyint NOT NULL, + `IF` tinyint NOT NULL, + `Id_Ticket` tinyint NOT NULL, + `warehouse_id` tinyint NOT NULL, + `Id_Consigna` tinyint NOT NULL, + `CodigoPais` tinyint NOT NULL, + `Fecha` tinyint NOT NULL, + `province_id` tinyint NOT NULL, + `landing` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `ticketNotInvoiced` -- @@ -37207,6 +37825,26 @@ CREATE TABLE `ticketPackagingStartingStock` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `ticketPackingList` +-- + +DROP TABLE IF EXISTS `ticketPackingList`; +/*!50001 DROP VIEW IF EXISTS `ticketPackingList`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ticketPackingList` ( + `nickname` tinyint NOT NULL, + `ticketFk` tinyint NOT NULL, + `agencyMode` tinyint NOT NULL, + `flag` tinyint NOT NULL, + `province` tinyint NOT NULL, + `itemFk` tinyint NOT NULL, + `concept` tinyint NOT NULL, + `quantity` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `ticketParking` -- @@ -37814,6 +38452,43 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `traceabilityBuy` +-- + +DROP TABLE IF EXISTS `traceabilityBuy`; +/*!50001 DROP VIEW IF EXISTS `traceabilityBuy`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `traceabilityBuy` ( + `buyFk` tinyint NOT NULL, + `quantity` tinyint NOT NULL, + `landed` tinyint NOT NULL, + `warehouseName` tinyint NOT NULL, + `entryFk` tinyint NOT NULL, + `supplierName` tinyint NOT NULL, + `itemFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `traceabilitySale` +-- + +DROP TABLE IF EXISTS `traceabilitySale`; +/*!50001 DROP VIEW IF EXISTS `traceabilitySale`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `traceabilitySale` ( + `ticketFk` tinyint NOT NULL, + `buyFk` tinyint NOT NULL, + `shipped` tinyint NOT NULL, + `nickname` tinyint NOT NULL, + `quantity` tinyint NOT NULL, + `worker` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `trainingCenter` -- @@ -38223,8 +38898,13 @@ DROP TABLE IF EXISTS `volumeConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `volumeConfig` ( - `espai` decimal(10,2) DEFAULT NULL, - `carro` decimal(10,2) DEFAULT NULL + `espai` decimal(10,2) DEFAULT NULL COMMENT 'metros cúbicos', + `carro` decimal(10,2) DEFAULT NULL COMMENT 'metros cúbicos', + `dutchCompressionRate` double NOT NULL DEFAULT '1', + `standardFlowerBox` int(11) NOT NULL COMMENT 'en litros', + `minCompressionRate` decimal(10,2) DEFAULT '0.30' COMMENT 'minimo permitido por la empresa', + `ccLength` int(11) NOT NULL DEFAULT '130' COMMENT 'longitud útil para la carga de un CC, en cm', + `ccWidth` int(11) NOT NULL DEFAULT '60' COMMENT 'ancho útil para la carga en un CC, en cm' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='almacena el valor standard para volumenes convencionales de Verdnatura, en metros cúbicos'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38293,11 +38973,16 @@ CREATE TABLE `warehouse` ( `aliasFk` smallint(5) unsigned DEFAULT NULL, `labelReport` int(11) DEFAULT NULL, `hasUbications` tinyint(1) NOT NULL DEFAULT '1', + `hasProduction` tinyint(1) NOT NULL DEFAULT '0', + `addressFk` int(11) DEFAULT NULL, + `hasMachine` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), KEY `isComparativeIdx` (`isComparative`), KEY `warehouse_ibfk_1_idx` (`aliasFk`), + KEY `warehouse_FK` (`addressFk`), + CONSTRAINT `warehouse_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`), CONSTRAINT `warehouse_ibfk_2` FOREIGN KEY (`aliasFk`) REFERENCES `warehouseAlias` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -38430,7 +39115,7 @@ CREATE TABLE `worker` ( `userFk` int(10) unsigned DEFAULT NULL, `bossFk` int(11) NOT NULL DEFAULT '103', `fiDueDate` datetime DEFAULT NULL, - `hasMachineryAutorized` tinyint(2) DEFAULT '0', + `hasMachineryAuthorized` tinyint(2) DEFAULT '0', `seniority` date DEFAULT NULL, `isTodayRelative` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', `isF11Allowed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Usuario autorizado para abrir el F11', @@ -38466,6 +39151,21 @@ CREATE TABLE `workerBosses` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `workerBusinessDated` +-- + +DROP TABLE IF EXISTS `workerBusinessDated`; +/*!50001 DROP VIEW IF EXISTS `workerBusinessDated`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `workerBusinessDated` ( + `dated` tinyint NOT NULL, + `business_id` tinyint NOT NULL, + `workerFk` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `workerCalendar` -- @@ -38547,6 +39247,23 @@ CREATE TABLE `workerDisableExcluded` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='No se deshabilitan hasta la fecha especificada'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerDistributionCategory` +-- + +DROP TABLE IF EXISTS `workerDistributionCategory`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerDistributionCategory` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `workerFk` int(11) NOT NULL, + `category` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `workerDistributionCategory_workerFk_idx` (`workerFk`), + CONSTRAINT `workerDistributionCategory_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerDocument` -- @@ -38797,6 +39514,29 @@ CREATE TABLE `workerRelatives` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Modelo 145 IRPF apartado 2 y 3'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerShelving` +-- + +DROP TABLE IF EXISTS `workerShelving`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerShelving` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `workerFk` int(11) NOT NULL, + `shelvingFk` varchar(10) CHARACTER SET utf8 NOT NULL, + `collectionFk` int(11) DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `workerShelving_shelving_fk` (`shelvingFk`), + KEY `workerShelving_FK` (`workerFk`), + KEY `workerShelving_FK_1` (`collectionFk`), + CONSTRAINT `workerShelving_collection_fk` FOREIGN KEY (`collectionFk`) REFERENCES `collection` (`id`), + CONSTRAINT `workerShelving_shelving_fk` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON UPDATE CASCADE, + CONSTRAINT `workerShelving_worker_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='utilizaremos el id para establecer la prioridad de los carros a asignar'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `workerSpeedExpedition` -- @@ -39672,14 +40412,14 @@ 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' */ ;; /*!50003 SET @saved_time_zone = @@time_zone */ ;; /*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 01:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN DECLARE vCurrentCount INT; DECLARE vCheckSum INT; @@ -39691,7 +40431,7 @@ DELIMITER ;; SELECT CONCAT('