diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql
index ce47886f8..60e568e8d 100644
--- a/db/dump/dumpedFixtures.sql
+++ b/db/dump/dumpedFixtures.sql
@@ -1,6 +1,6 @@
USE `util`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: util
-- ------------------------------------------------------
@@ -9,7 +9,7 @@ USE `util`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -34,9 +34,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:27:51
+-- Dump completed on 2022-03-28 9:44:13
USE `account`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: account
-- ------------------------------------------------------
@@ -45,7 +45,7 @@ USE `account`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -78,7 +78,7 @@ UNLOCK TABLES;
LOCK TABLES `roleRole` WRITE;
/*!40000 ALTER TABLE `roleRole` DISABLE KEYS */;
-INSERT INTO `roleRole` VALUES (84435,1,1),(84436,1,2),(84437,1,3),(84440,1,6),(84439,1,11),(84438,1,70),(84353,2,2),(84355,2,6),(84354,2,11),(84238,3,3),(84240,3,6),(84239,3,11),(84208,5,1),(84215,5,2),(84214,5,3),(84207,5,5),(84220,5,6),(84219,5,11),(84212,5,13),(84216,5,18),(84209,5,21),(84210,5,33),(84217,5,53),(84213,5,70),(84218,5,72),(84211,5,76),(84537,6,6),(84376,9,1),(84377,9,2),(84378,9,3),(84379,9,5),(84380,9,6),(84374,9,9),(84381,9,11),(84382,9,13),(84383,9,15),(84384,9,16),(84385,9,17),(84386,9,18),(84387,9,19),(84388,9,20),(84389,9,21),(84390,9,22),(84391,9,30),(84392,9,31),(84393,9,32),(84394,9,33),(84395,9,34),(84396,9,35),(84397,9,36),(84398,9,37),(84399,9,38),(84400,9,39),(84401,9,40),(84402,9,41),(84403,9,42),(84404,9,43),(84405,9,44),(84406,9,45),(84407,9,47),(84408,9,48),(84409,9,49),(84410,9,50),(84411,9,51),(84412,9,52),(84413,9,53),(84414,9,54),(84415,9,55),(84416,9,56),(84417,9,57),(84418,9,58),(84419,9,59),(84420,9,60),(84421,9,61),(84422,9,64),(84423,9,65),(84424,9,67),(84425,9,69),(84426,9,70),(84427,9,71),(84428,9,72),(84429,9,73),(84430,9,74),(84431,9,75),(84432,9,76),(84433,9,101),(84434,9,102),(84375,9,103),(84128,11,6),(84127,11,11),(85200,13,1),(85201,13,2),(85202,13,3),(85205,13,6),(85204,13,11),(85199,13,13),(85203,13,70),(84749,15,1),(84753,15,2),(84752,15,3),(84756,15,6),(84755,15,11),(84741,15,15),(84742,15,35),(84747,15,36),(84750,15,44),(84754,15,47),(84743,15,49),(84744,15,56),(84746,15,58),(84751,15,70),(84748,15,75),(84745,15,76),(84763,16,1),(84768,16,2),(84767,16,3),(84774,16,6),(84773,16,11),(84758,16,13),(84759,16,15),(84757,16,16),(84762,16,35),(84769,16,36),(84772,16,44),(84771,16,47),(84761,16,49),(84764,16,56),(84770,16,58),(84766,16,70),(84765,16,75),(84760,16,76),(84154,17,1),(84165,17,2),(84164,17,3),(84159,17,5),(84187,17,6),(84158,17,9),(84186,17,11),(84157,17,13),(84169,17,15),(84156,17,16),(84146,17,17),(84171,17,18),(84168,17,19),(84147,17,20),(84160,17,21),(84185,17,22),(84184,17,30),(84183,17,31),(84182,17,32),(84162,17,33),(84181,17,34),(84167,17,35),(84180,17,36),(84148,17,37),(84179,17,38),(84149,17,39),(84178,17,40),(84177,17,41),(84176,17,42),(84175,17,43),(84188,17,44),(84189,17,45),(84190,17,47),(84191,17,48),(84192,17,49),(84166,17,50),(84193,17,51),(84194,17,52),(84172,17,53),(84195,17,54),(84196,17,55),(84174,17,56),(84161,17,57),(84197,17,58),(84198,17,59),(84199,17,60),(84200,17,61),(84150,17,64),(84155,17,65),(84151,17,67),(84201,17,69),(84163,17,70),(84202,17,71),(84173,17,72),(84203,17,73),(84153,17,74),(84204,17,75),(84152,17,76),(84205,17,101),(84206,17,102),(84170,17,103),(85130,18,1),(85133,18,2),(85132,18,3),(85136,18,6),(85135,18,11),(85129,18,18),(85134,18,70),(85131,18,76),(85123,19,1),(85126,19,2),(85125,19,3),(85128,19,6),(85127,19,11),(85118,19,13),(85119,19,18),(85116,19,19),(85117,19,21),(85120,19,53),(85124,19,70),(85121,19,72),(85122,19,76),(84784,20,1),(84792,20,2),(84791,20,3),(84790,20,5),(84789,20,6),(84776,20,9),(84788,20,11),(84777,20,13),(84783,20,15),(84778,20,16),(84787,20,17),(84793,20,18),(84782,20,19),(84775,20,20),(84794,20,21),(84795,20,22),(84796,20,30),(84797,20,31),(84798,20,32),(84799,20,33),(84800,20,34),(84781,20,35),(84801,20,36),(84802,20,37),(84803,20,38),(84804,20,39),(84805,20,40),(84806,20,41),(84807,20,42),(84808,20,43),(84809,20,44),(84810,20,45),(84811,20,47),(84812,20,48),(84813,20,49),(84786,20,50),(84814,20,51),(84815,20,52),(84816,20,53),(84817,20,54),(84818,20,55),(84819,20,56),(84820,20,57),(84821,20,58),(84822,20,59),(84823,20,60),(84824,20,61),(84825,20,64),(84779,20,65),(84826,20,67),(84827,20,69),(84828,20,70),(84829,20,71),(84830,20,72),(84831,20,73),(84832,20,74),(84833,20,75),(84780,20,76),(84834,20,101),(84835,20,102),(84785,20,103),(85110,21,1),(85113,21,2),(85112,21,3),(85115,21,6),(85114,21,11),(85105,21,13),(85106,21,18),(85104,21,21),(85107,21,53),(85111,21,70),(85108,21,72),(85109,21,76),(85210,22,1),(85216,22,2),(85215,22,3),(85218,22,6),(85217,22,11),(85207,22,13),(85209,22,18),(85208,22,21),(85206,22,22),(85211,22,53),(85214,22,70),(85212,22,72),(85213,22,76),(84480,30,1),(84488,30,2),(84487,30,3),(84469,30,5),(84500,30,6),(84477,30,9),(84501,30,11),(84476,30,13),(84482,30,15),(84475,30,16),(84499,30,17),(84485,30,18),(84489,30,19),(84470,30,20),(84479,30,21),(84471,30,22),(84468,30,30),(84498,30,31),(84497,30,32),(84478,30,33),(84496,30,34),(84490,30,35),(84495,30,36),(84494,30,37),(84493,30,38),(84492,30,39),(84502,30,40),(84503,30,41),(84504,30,42),(84505,30,43),(84506,30,44),(84507,30,45),(84508,30,47),(84509,30,48),(84510,30,49),(84491,30,50),(84511,30,51),(84512,30,52),(84472,30,53),(84513,30,54),(84514,30,55),(84515,30,56),(84516,30,57),(84517,30,58),(84518,30,59),(84519,30,60),(84520,30,61),(84473,30,64),(84481,30,65),(84521,30,67),(84522,30,69),(84486,30,70),(84523,30,71),(84484,30,72),(84524,30,73),(84525,30,74),(84526,30,75),(84474,30,76),(84527,30,101),(84528,30,102),(84483,30,103),(84530,31,1),(84531,31,2),(84532,31,3),(84535,31,6),(84534,31,11),(84529,31,31),(84533,31,70),(84442,32,1),(84443,32,2),(84444,32,3),(84447,32,6),(84446,32,11),(84441,32,32),(84445,32,70),(84595,33,33),(84242,34,1),(84247,34,2),(84246,34,3),(84249,34,6),(84248,34,11),(84243,34,13),(84244,34,33),(84241,34,34),(84245,34,70),(84284,35,1),(84289,35,2),(84288,35,3),(84291,35,6),(84290,35,11),(84283,35,35),(84287,35,70),(84285,35,75),(84286,35,76),(85019,36,1),(85021,36,2),(85020,36,3),(85024,36,6),(85023,36,11),(85016,36,36),(85017,36,44),(85018,36,47),(85022,36,70),(84568,37,1),(84573,37,2),(84572,37,3),(84575,37,6),(84574,37,11),(84567,37,37),(84571,37,70),(84569,37,74),(84570,37,76),(84582,38,1),(84585,38,2),(84584,38,3),(84587,38,6),(84586,38,11),(84577,38,13),(84578,38,37),(84576,38,38),(84579,38,64),(84583,38,70),(84581,38,74),(84580,38,76),(84137,39,1),(84143,39,2),(84142,39,3),(84130,39,5),(84145,39,6),(84144,39,11),(84135,39,13),(84134,39,18),(84131,39,21),(84136,39,33),(84129,39,39),(84138,39,53),(84140,39,56),(84132,39,57),(84141,39,70),(84139,39,72),(84133,39,76),(84539,40,1),(84542,40,2),(84541,40,3),(84549,40,6),(84548,40,11),(84544,40,36),(84538,40,40),(84547,40,44),(84546,40,47),(84540,40,49),(84545,40,58),(84543,40,70),(84557,41,1),(84561,41,2),(84560,41,3),(84566,41,6),(84565,41,11),(84551,41,13),(84552,41,35),(84558,41,36),(84553,41,40),(84550,41,41),(84564,41,44),(84563,41,47),(84555,41,49),(84562,41,58),(84559,41,70),(84556,41,75),(84554,41,76),(84256,42,1),(84261,42,2),(84260,42,3),(84264,42,6),(84263,42,11),(84251,42,35),(84254,42,36),(84250,42,42),(84258,42,44),(84262,42,47),(84252,42,49),(84257,42,58),(84259,42,70),(84255,42,75),(84253,42,76),(84269,43,1),(84275,43,2),(84274,43,3),(84281,43,6),(84280,43,11),(84266,43,13),(84268,43,35),(84276,43,36),(84267,43,42),(84265,43,43),(84279,43,44),(84278,43,47),(84270,43,49),(84277,43,58),(84273,43,70),(84272,43,75),(84271,43,76),(84112,44,1),(84113,44,2),(84114,44,3),(84117,44,6),(84116,44,11),(84111,44,44),(84115,44,70),(84121,45,1),(84123,45,2),(84122,45,3),(84126,45,6),(84125,45,11),(84119,45,13),(84120,45,44),(84118,45,45),(84124,45,70),(84324,47,1),(84325,47,2),(84326,47,3),(84329,47,6),(84328,47,11),(84323,47,47),(84327,47,70),(84347,48,1),(84350,48,2),(84349,48,3),(84352,48,6),(84351,48,11),(84342,48,13),(84343,48,35),(84344,48,47),(84341,48,48),(84348,48,70),(84346,48,75),(84345,48,76),(84933,49,1),(84936,49,2),(84935,49,3),(84938,49,6),(84937,49,11),(84929,49,36),(84932,49,44),(84931,49,47),(84928,49,49),(84930,49,58),(84934,49,70),(84979,50,1),(84986,50,2),(84985,50,3),(84988,50,6),(84987,50,11),(84966,50,13),(84978,50,18),(84967,50,21),(84980,50,33),(84968,50,35),(84974,50,36),(84983,50,44),(84982,50,47),(84969,50,49),(84965,50,50),(84977,50,53),(84981,50,56),(84970,50,57),(84973,50,58),(84971,50,59),(84984,50,70),(84976,50,72),(84975,50,75),(84972,50,76),(84837,51,1),(84842,51,2),(84841,51,3),(84844,51,6),(84843,51,11),(84836,51,51),(84840,51,70),(84838,51,74),(84839,51,75),(84854,52,1),(84859,52,2),(84858,52,3),(84862,52,6),(84861,52,11),(84846,52,13),(84856,52,18),(84847,52,19),(84853,52,21),(84848,52,35),(84849,52,51),(84845,52,52),(84855,52,53),(84857,52,70),(84860,52,72),(84851,52,74),(84852,52,75),(84850,52,76),(84589,53,1),(84590,53,2),(84591,53,3),(84594,53,6),(84593,53,11),(84588,53,53),(84592,53,70),(84726,54,1),(84727,54,2),(84728,54,3),(84731,54,6),(84730,54,11),(84725,54,54),(84729,54,70),(84735,55,1),(84737,55,2),(84736,55,3),(84740,55,6),(84739,55,11),(84733,55,13),(84734,55,54),(84732,55,55),(84738,55,70),(84357,56,1),(84358,56,2),(84359,56,3),(84362,56,6),(84361,56,11),(84356,56,56),(84360,56,70),(84368,57,1),(84371,57,2),(84370,57,3),(84373,57,6),(84372,57,11),(84364,57,13),(84365,57,33),(84366,57,56),(84363,57,57),(84369,57,70),(84367,57,76),(84891,58,1),(84892,58,2),(84893,58,3),(84896,58,6),(84895,58,11),(84890,58,58),(84894,58,70),(84901,59,1),(84911,59,2),(84910,59,3),(84920,59,6),(84919,59,11),(84898,59,13),(84908,59,18),(84900,59,21),(84915,59,33),(84902,59,35),(84913,59,36),(84918,59,44),(84917,59,47),(84903,59,49),(84899,59,50),(84907,59,53),(84916,59,56),(84904,59,57),(84914,59,58),(84897,59,59),(84909,59,70),(84906,59,72),(84912,59,75),(84905,59,76),(84947,60,1),(84959,60,2),(84958,60,3),(84940,60,5),(84964,60,6),(84963,60,11),(84944,60,13),(84956,60,18),(84946,60,21),(84945,60,33),(84948,60,35),(84952,60,36),(84962,60,44),(84961,60,47),(84949,60,49),(84941,60,50),(84955,60,53),(84951,60,56),(84942,60,57),(84960,60,58),(84950,60,59),(84939,60,60),(84957,60,70),(84954,60,72),(84953,60,75),(84943,60,76),(85029,61,1),(85033,61,2),(85032,61,3),(85035,61,6),(85034,61,11),(85026,61,13),(85027,61,36),(85028,61,44),(85030,61,47),(85025,61,61),(85031,61,70),(84863,62,62),(84282,64,64),(84871,65,1),(84879,65,2),(84878,65,3),(84889,65,6),(84888,65,11),(84869,65,13),(84882,65,18),(84865,65,19),(84872,65,21),(84884,65,33),(84866,65,35),(84876,65,36),(84887,65,44),(84886,65,47),(84873,65,49),(84867,65,50),(84881,65,53),(84885,65,56),(84874,65,57),(84883,65,58),(84875,65,59),(84864,65,65),(84877,65,70),(84880,65,72),(84870,65,75),(84868,65,76),(85141,66,1),(85140,66,2),(85142,66,3),(85143,66,5),(85144,66,6),(85138,66,9),(85145,66,11),(85146,66,13),(85147,66,15),(85148,66,16),(85149,66,17),(85150,66,18),(85151,66,19),(85152,66,20),(85153,66,21),(85154,66,22),(85155,66,30),(85156,66,31),(85157,66,32),(85158,66,33),(85159,66,34),(85160,66,35),(85161,66,36),(85162,66,37),(85163,66,38),(85164,66,39),(85165,66,40),(85166,66,41),(85167,66,42),(85168,66,43),(85169,66,44),(85170,66,45),(85171,66,47),(85172,66,48),(85173,66,49),(85174,66,50),(85175,66,51),(85176,66,52),(85177,66,53),(85178,66,54),(85179,66,55),(85180,66,56),(85181,66,57),(85182,66,58),(85183,66,59),(85184,66,60),(85185,66,61),(85186,66,64),(85187,66,65),(85137,66,66),(85188,66,67),(85189,66,69),(85190,66,70),(85191,66,71),(85192,66,72),(85193,66,73),(85194,66,74),(85195,66,75),(85196,66,76),(85197,66,101),(85198,66,102),(85139,66,103),(84225,67,1),(84233,67,2),(84232,67,3),(84222,67,5),(84237,67,6),(84236,67,11),(84230,67,13),(84229,67,18),(84224,67,21),(84226,67,33),(84223,67,37),(84234,67,53),(84221,67,67),(84231,67,70),(84235,67,72),(84228,67,74),(84227,67,76),(84334,69,1),(84338,69,2),(84337,69,3),(84340,69,6),(84339,69,11),(84331,69,35),(84332,69,47),(84330,69,69),(84336,69,70),(84333,69,75),(84335,69,76),(85221,70,6),(85220,70,11),(85219,70,70),(84306,71,1),(84309,71,2),(84308,71,3),(84312,71,6),(84311,71,11),(84307,71,58),(84310,71,70),(84305,71,71),(84317,72,1),(84319,72,2),(84318,72,3),(84322,72,6),(84321,72,11),(84314,72,13),(84315,72,18),(84320,72,70),(84313,72,72),(84316,72,76),(84457,73,1),(84462,73,2),(84461,73,3),(84452,73,5),(84467,73,6),(84466,73,11),(84459,73,13),(84463,73,18),(84453,73,19),(84456,73,21),(84455,73,33),(84464,73,53),(84454,73,64),(84460,73,70),(84465,73,72),(84451,73,73),(84458,73,76),(85222,74,74),(84303,75,75),(84304,76,76),(85062,100,1),(85058,100,2),(85044,100,3),(85042,100,5),(85069,100,6),(85061,100,9),(85039,100,11),(85100,100,13),(85080,100,15),(85081,100,16),(85041,100,17),(85098,100,18),(85097,100,19),(85082,100,20),(85096,100,21),(85101,100,22),(85066,100,30),(85067,100,31),(85063,100,32),(85075,100,33),(85045,100,34),(85049,100,35),(85094,100,36),(85072,100,37),(85073,100,38),(85040,100,39),(85070,100,40),(85071,100,41),(85046,100,42),(85047,100,43),(85037,100,44),(85038,100,45),(85055,100,47),(85057,100,48),(85090,100,49),(85092,100,50),(85083,100,51),(85084,100,52),(85074,100,53),(85078,100,54),(85079,100,55),(85059,100,56),(85060,100,57),(85087,100,58),(85088,100,59),(85091,100,60),(85095,100,61),(85085,100,62),(85048,100,64),(85086,100,65),(85099,100,66),(85043,100,67),(85056,100,69),(85102,100,70),(85053,100,71),(85054,100,72),(85065,100,73),(85103,100,74),(85051,100,75),(85052,100,76),(85036,100,100),(85050,100,101),(85089,100,102),(85076,100,103),(85077,100,104),(85068,100,105),(85064,100,106),(85093,100,107),(84296,101,1),(84300,101,2),(84299,101,3),(84302,101,6),(84301,101,11),(84293,101,13),(84294,101,35),(84298,101,70),(84295,101,75),(84297,101,76),(84292,101,101),(84922,102,1),(84923,102,2),(84924,102,3),(84927,102,6),(84926,102,11),(84925,102,70),(84921,102,102),(84597,103,1),(84598,103,2),(84599,103,3),(84600,103,5),(84601,103,6),(84656,103,9),(84602,103,11),(84603,103,13),(84604,103,15),(84605,103,16),(84606,103,17),(84607,103,18),(84608,103,19),(84609,103,20),(84610,103,21),(84611,103,22),(84612,103,30),(84613,103,31),(84614,103,32),(84615,103,33),(84616,103,34),(84617,103,35),(84618,103,36),(84619,103,37),(84620,103,38),(84621,103,39),(84622,103,40),(84623,103,41),(84624,103,42),(84625,103,43),(84626,103,44),(84627,103,45),(84628,103,47),(84629,103,48),(84630,103,49),(84631,103,50),(84632,103,51),(84633,103,52),(84634,103,53),(84635,103,54),(84636,103,55),(84637,103,56),(84638,103,57),(84639,103,58),(84640,103,59),(84641,103,60),(84642,103,61),(84643,103,64),(84644,103,65),(84645,103,67),(84646,103,69),(84647,103,70),(84648,103,71),(84649,103,72),(84650,103,73),(84651,103,74),(84652,103,75),(84653,103,76),(84654,103,101),(84655,103,102),(84596,103,103),(84665,104,1),(84664,104,2),(84663,104,3),(84662,104,5),(84666,104,6),(84658,104,9),(84667,104,11),(84668,104,13),(84669,104,15),(84670,104,16),(84671,104,17),(84672,104,18),(84673,104,19),(84674,104,20),(84675,104,21),(84676,104,22),(84677,104,30),(84678,104,31),(84679,104,32),(84680,104,33),(84681,104,34),(84682,104,35),(84683,104,36),(84684,104,37),(84685,104,38),(84686,104,39),(84687,104,40),(84688,104,41),(84689,104,42),(84690,104,43),(84691,104,44),(84692,104,45),(84693,104,47),(84694,104,48),(84695,104,49),(84696,104,50),(84697,104,51),(84698,104,52),(84699,104,53),(84700,104,54),(84701,104,55),(84702,104,56),(84703,104,57),(84704,104,58),(84705,104,59),(84706,104,60),(84707,104,61),(84723,104,62),(84708,104,64),(84709,104,65),(84659,104,66),(84710,104,67),(84711,104,69),(84712,104,70),(84713,104,71),(84714,104,72),(84715,104,73),(84716,104,74),(84717,104,75),(84718,104,76),(84660,104,100),(84719,104,101),(84720,104,102),(84661,104,103),(84657,104,104),(84722,104,105),(84721,104,106),(84724,104,107),(84536,105,105),(84450,106,6),(84449,106,11),(84448,106,106),(84998,107,1),(85010,107,2),(85009,107,3),(84991,107,5),(85015,107,6),(85014,107,11),(84995,107,13),(85007,107,18),(84997,107,21),(84996,107,33),(84999,107,35),(85003,107,36),(85013,107,44),(85012,107,47),(85000,107,49),(84992,107,50),(85006,107,53),(85002,107,56),(84993,107,57),(85011,107,58),(85001,107,59),(84990,107,60),(85008,107,70),(85005,107,72),(85004,107,75),(84994,107,76),(84989,107,107);
+INSERT INTO `roleRole` VALUES (85547,1,1),(85548,1,2),(85549,1,3),(85552,1,6),(85551,1,11),(85550,1,70),(85465,2,2),(85467,2,6),(85466,2,11),(85350,3,3),(85352,3,6),(85351,3,11),(85320,5,1),(85327,5,2),(85326,5,3),(85319,5,5),(85332,5,6),(85331,5,11),(85324,5,13),(85328,5,18),(85321,5,21),(85322,5,33),(85329,5,53),(85325,5,70),(85330,5,72),(85323,5,76),(85649,6,6),(85488,9,1),(85489,9,2),(85490,9,3),(85491,9,5),(85492,9,6),(85486,9,9),(85493,9,11),(85494,9,13),(85495,9,15),(85496,9,16),(85497,9,17),(85498,9,18),(85499,9,19),(85500,9,20),(85501,9,21),(85502,9,22),(85503,9,30),(85504,9,31),(85505,9,32),(85506,9,33),(85507,9,34),(85508,9,35),(85509,9,36),(85510,9,37),(85511,9,38),(85512,9,39),(85513,9,40),(85514,9,41),(85515,9,42),(85516,9,43),(85517,9,44),(85518,9,45),(85519,9,47),(85520,9,48),(85521,9,49),(85522,9,50),(85523,9,51),(85524,9,52),(85525,9,53),(85526,9,54),(85527,9,55),(85528,9,56),(85529,9,57),(85530,9,58),(85531,9,59),(85532,9,60),(85533,9,61),(85534,9,64),(85535,9,65),(85536,9,67),(85537,9,69),(85538,9,70),(85539,9,71),(85540,9,72),(85541,9,73),(85542,9,74),(85543,9,75),(85544,9,76),(85545,9,101),(85546,9,102),(85487,9,103),(85240,11,6),(85239,11,11),(86312,13,1),(86313,13,2),(86314,13,3),(86317,13,6),(86316,13,11),(86311,13,13),(86315,13,70),(85861,15,1),(85865,15,2),(85864,15,3),(85868,15,6),(85867,15,11),(85853,15,15),(85854,15,35),(85859,15,36),(85862,15,44),(85866,15,47),(85855,15,49),(85856,15,56),(85858,15,58),(85863,15,70),(85860,15,75),(85857,15,76),(85875,16,1),(85880,16,2),(85879,16,3),(85886,16,6),(85885,16,11),(85870,16,13),(85871,16,15),(85869,16,16),(85874,16,35),(85881,16,36),(85884,16,44),(85883,16,47),(85873,16,49),(85876,16,56),(85882,16,58),(85878,16,70),(85877,16,75),(85872,16,76),(85266,17,1),(85277,17,2),(85276,17,3),(85271,17,5),(85299,17,6),(85270,17,9),(85298,17,11),(85269,17,13),(85281,17,15),(85268,17,16),(85258,17,17),(85283,17,18),(85280,17,19),(85259,17,20),(85272,17,21),(85297,17,22),(85296,17,30),(85295,17,31),(85294,17,32),(85274,17,33),(85293,17,34),(85279,17,35),(85292,17,36),(85260,17,37),(85291,17,38),(85261,17,39),(85290,17,40),(85289,17,41),(85288,17,42),(85287,17,43),(85300,17,44),(85301,17,45),(85302,17,47),(85303,17,48),(85304,17,49),(85278,17,50),(85305,17,51),(85306,17,52),(85284,17,53),(85307,17,54),(85308,17,55),(85286,17,56),(85273,17,57),(85309,17,58),(85310,17,59),(85311,17,60),(85312,17,61),(85262,17,64),(85267,17,65),(85263,17,67),(85313,17,69),(85275,17,70),(85314,17,71),(85285,17,72),(85315,17,73),(85265,17,74),(85316,17,75),(85264,17,76),(85317,17,101),(85318,17,102),(85282,17,103),(86242,18,1),(86245,18,2),(86244,18,3),(86248,18,6),(86247,18,11),(86241,18,18),(86246,18,70),(86243,18,76),(86235,19,1),(86238,19,2),(86237,19,3),(86240,19,6),(86239,19,11),(86230,19,13),(86231,19,18),(86228,19,19),(86229,19,21),(86232,19,53),(86236,19,70),(86233,19,72),(86234,19,76),(85896,20,1),(85904,20,2),(85903,20,3),(85902,20,5),(85901,20,6),(85888,20,9),(85900,20,11),(85889,20,13),(85895,20,15),(85890,20,16),(85899,20,17),(85905,20,18),(85894,20,19),(85887,20,20),(85906,20,21),(85907,20,22),(85908,20,30),(85909,20,31),(85910,20,32),(85911,20,33),(85912,20,34),(85893,20,35),(85913,20,36),(85914,20,37),(85915,20,38),(85916,20,39),(85917,20,40),(85918,20,41),(85919,20,42),(85920,20,43),(85921,20,44),(85922,20,45),(85923,20,47),(85924,20,48),(85925,20,49),(85898,20,50),(85926,20,51),(85927,20,52),(85928,20,53),(85929,20,54),(85930,20,55),(85931,20,56),(85932,20,57),(85933,20,58),(85934,20,59),(85935,20,60),(85936,20,61),(85937,20,64),(85891,20,65),(85938,20,67),(85939,20,69),(85940,20,70),(85941,20,71),(85942,20,72),(85943,20,73),(85944,20,74),(85945,20,75),(85892,20,76),(85946,20,101),(85947,20,102),(85897,20,103),(86222,21,1),(86225,21,2),(86224,21,3),(86227,21,6),(86226,21,11),(86217,21,13),(86218,21,18),(86216,21,21),(86219,21,53),(86223,21,70),(86220,21,72),(86221,21,76),(86322,22,1),(86328,22,2),(86327,22,3),(86330,22,6),(86329,22,11),(86319,22,13),(86321,22,18),(86320,22,21),(86318,22,22),(86323,22,53),(86326,22,70),(86324,22,72),(86325,22,76),(85592,30,1),(85600,30,2),(85599,30,3),(85581,30,5),(85612,30,6),(85589,30,9),(85613,30,11),(85588,30,13),(85594,30,15),(85587,30,16),(85611,30,17),(85597,30,18),(85601,30,19),(85582,30,20),(85591,30,21),(85583,30,22),(85580,30,30),(85610,30,31),(85609,30,32),(85590,30,33),(85608,30,34),(85602,30,35),(85607,30,36),(85606,30,37),(85605,30,38),(85604,30,39),(85614,30,40),(85615,30,41),(85616,30,42),(85617,30,43),(85618,30,44),(85619,30,45),(85620,30,47),(85621,30,48),(85622,30,49),(85603,30,50),(85623,30,51),(85624,30,52),(85584,30,53),(85625,30,54),(85626,30,55),(85627,30,56),(85628,30,57),(85629,30,58),(85630,30,59),(85631,30,60),(85632,30,61),(85585,30,64),(85593,30,65),(85633,30,67),(85634,30,69),(85598,30,70),(85635,30,71),(85596,30,72),(85636,30,73),(85637,30,74),(85638,30,75),(85586,30,76),(85639,30,101),(85640,30,102),(85595,30,103),(85642,31,1),(85643,31,2),(85644,31,3),(85647,31,6),(85646,31,11),(85641,31,31),(85645,31,70),(85554,32,1),(85555,32,2),(85556,32,3),(85559,32,6),(85558,32,11),(85553,32,32),(85557,32,70),(85707,33,33),(85354,34,1),(85359,34,2),(85358,34,3),(85361,34,6),(85360,34,11),(85355,34,13),(85356,34,33),(85353,34,34),(85357,34,70),(85396,35,1),(85401,35,2),(85400,35,3),(85403,35,6),(85402,35,11),(85395,35,35),(85399,35,70),(85397,35,75),(85398,35,76),(86131,36,1),(86133,36,2),(86132,36,3),(86136,36,6),(86135,36,11),(86128,36,36),(86129,36,44),(86130,36,47),(86134,36,70),(85680,37,1),(85685,37,2),(85684,37,3),(85687,37,6),(85686,37,11),(85679,37,37),(85683,37,70),(85681,37,74),(85682,37,76),(85694,38,1),(85697,38,2),(85696,38,3),(85699,38,6),(85698,38,11),(85689,38,13),(85690,38,37),(85688,38,38),(85691,38,64),(85695,38,70),(85693,38,74),(85692,38,76),(85249,39,1),(85255,39,2),(85254,39,3),(85242,39,5),(85257,39,6),(85256,39,11),(85247,39,13),(85246,39,18),(85243,39,21),(85248,39,33),(85241,39,39),(85250,39,53),(85252,39,56),(85244,39,57),(85253,39,70),(85251,39,72),(85245,39,76),(85651,40,1),(85654,40,2),(85653,40,3),(85661,40,6),(85660,40,11),(85656,40,36),(85650,40,40),(85659,40,44),(85658,40,47),(85652,40,49),(85657,40,58),(85655,40,70),(85669,41,1),(85673,41,2),(85672,41,3),(85678,41,6),(85677,41,11),(85663,41,13),(85664,41,35),(85670,41,36),(85665,41,40),(85662,41,41),(85676,41,44),(85675,41,47),(85667,41,49),(85674,41,58),(85671,41,70),(85668,41,75),(85666,41,76),(85368,42,1),(85373,42,2),(85372,42,3),(85376,42,6),(85375,42,11),(85363,42,35),(85366,42,36),(85362,42,42),(85370,42,44),(85374,42,47),(85364,42,49),(85369,42,58),(85371,42,70),(85367,42,75),(85365,42,76),(85381,43,1),(85387,43,2),(85386,43,3),(85393,43,6),(85392,43,11),(85378,43,13),(85380,43,35),(85388,43,36),(85379,43,42),(85377,43,43),(85391,43,44),(85390,43,47),(85382,43,49),(85389,43,58),(85385,43,70),(85384,43,75),(85383,43,76),(85224,44,1),(85225,44,2),(85226,44,3),(85229,44,6),(85228,44,11),(85223,44,44),(85227,44,70),(85233,45,1),(85235,45,2),(85234,45,3),(85238,45,6),(85237,45,11),(85231,45,13),(85232,45,44),(85230,45,45),(85236,45,70),(85436,47,1),(85437,47,2),(85438,47,3),(85441,47,6),(85440,47,11),(85435,47,47),(85439,47,70),(85459,48,1),(85462,48,2),(85461,48,3),(85464,48,6),(85463,48,11),(85454,48,13),(85455,48,35),(85456,48,47),(85453,48,48),(85460,48,70),(85458,48,75),(85457,48,76),(86045,49,1),(86048,49,2),(86047,49,3),(86050,49,6),(86049,49,11),(86041,49,36),(86044,49,44),(86043,49,47),(86040,49,49),(86042,49,58),(86046,49,70),(86091,50,1),(86098,50,2),(86097,50,3),(86100,50,6),(86099,50,11),(86078,50,13),(86090,50,18),(86079,50,21),(86092,50,33),(86080,50,35),(86086,50,36),(86095,50,44),(86094,50,47),(86081,50,49),(86077,50,50),(86089,50,53),(86093,50,56),(86082,50,57),(86085,50,58),(86083,50,59),(86096,50,70),(86088,50,72),(86087,50,75),(86084,50,76),(85949,51,1),(85954,51,2),(85953,51,3),(85956,51,6),(85955,51,11),(85948,51,51),(85952,51,70),(85950,51,74),(85951,51,75),(85966,52,1),(85971,52,2),(85970,52,3),(85974,52,6),(85973,52,11),(85958,52,13),(85968,52,18),(85959,52,19),(85965,52,21),(85960,52,35),(85961,52,51),(85957,52,52),(85967,52,53),(85969,52,70),(85972,52,72),(85963,52,74),(85964,52,75),(85962,52,76),(85701,53,1),(85702,53,2),(85703,53,3),(85706,53,6),(85705,53,11),(85700,53,53),(85704,53,70),(85838,54,1),(85839,54,2),(85840,54,3),(85843,54,6),(85842,54,11),(85837,54,54),(85841,54,70),(85847,55,1),(85849,55,2),(85848,55,3),(85852,55,6),(85851,55,11),(85845,55,13),(85846,55,54),(85844,55,55),(85850,55,70),(85469,56,1),(85470,56,2),(85471,56,3),(85474,56,6),(85473,56,11),(85468,56,56),(85472,56,70),(85480,57,1),(85483,57,2),(85482,57,3),(85485,57,6),(85484,57,11),(85476,57,13),(85477,57,33),(85478,57,56),(85475,57,57),(85481,57,70),(85479,57,76),(86003,58,1),(86004,58,2),(86005,58,3),(86008,58,6),(86007,58,11),(86002,58,58),(86006,58,70),(86013,59,1),(86023,59,2),(86022,59,3),(86032,59,6),(86031,59,11),(86010,59,13),(86020,59,18),(86012,59,21),(86027,59,33),(86014,59,35),(86025,59,36),(86030,59,44),(86029,59,47),(86015,59,49),(86011,59,50),(86019,59,53),(86028,59,56),(86016,59,57),(86026,59,58),(86009,59,59),(86021,59,70),(86018,59,72),(86024,59,75),(86017,59,76),(86059,60,1),(86071,60,2),(86070,60,3),(86052,60,5),(86076,60,6),(86075,60,11),(86056,60,13),(86068,60,18),(86058,60,21),(86057,60,33),(86060,60,35),(86064,60,36),(86074,60,44),(86073,60,47),(86061,60,49),(86053,60,50),(86067,60,53),(86063,60,56),(86054,60,57),(86072,60,58),(86062,60,59),(86051,60,60),(86069,60,70),(86066,60,72),(86065,60,75),(86055,60,76),(86141,61,1),(86145,61,2),(86144,61,3),(86147,61,6),(86146,61,11),(86138,61,13),(86139,61,36),(86140,61,44),(86142,61,47),(86137,61,61),(86143,61,70),(85975,62,62),(85394,64,64),(85983,65,1),(85991,65,2),(85990,65,3),(86001,65,6),(86000,65,11),(85981,65,13),(85994,65,18),(85977,65,19),(85984,65,21),(85996,65,33),(85978,65,35),(85988,65,36),(85999,65,44),(85998,65,47),(85985,65,49),(85979,65,50),(85993,65,53),(85997,65,56),(85986,65,57),(85995,65,58),(85987,65,59),(85976,65,65),(85989,65,70),(85992,65,72),(85982,65,75),(85980,65,76),(86253,66,1),(86252,66,2),(86254,66,3),(86255,66,5),(86256,66,6),(86250,66,9),(86257,66,11),(86258,66,13),(86259,66,15),(86260,66,16),(86261,66,17),(86262,66,18),(86263,66,19),(86264,66,20),(86265,66,21),(86266,66,22),(86267,66,30),(86268,66,31),(86269,66,32),(86270,66,33),(86271,66,34),(86272,66,35),(86273,66,36),(86274,66,37),(86275,66,38),(86276,66,39),(86277,66,40),(86278,66,41),(86279,66,42),(86280,66,43),(86281,66,44),(86282,66,45),(86283,66,47),(86284,66,48),(86285,66,49),(86286,66,50),(86287,66,51),(86288,66,52),(86289,66,53),(86290,66,54),(86291,66,55),(86292,66,56),(86293,66,57),(86294,66,58),(86295,66,59),(86296,66,60),(86297,66,61),(86298,66,64),(86299,66,65),(86249,66,66),(86300,66,67),(86301,66,69),(86302,66,70),(86303,66,71),(86304,66,72),(86305,66,73),(86306,66,74),(86307,66,75),(86308,66,76),(86309,66,101),(86310,66,102),(86251,66,103),(85337,67,1),(85345,67,2),(85344,67,3),(85334,67,5),(85349,67,6),(85348,67,11),(85342,67,13),(85341,67,18),(85336,67,21),(85338,67,33),(85335,67,37),(85346,67,53),(85333,67,67),(85343,67,70),(85347,67,72),(85340,67,74),(85339,67,76),(85446,69,1),(85450,69,2),(85449,69,3),(85452,69,6),(85451,69,11),(85443,69,35),(85444,69,47),(85442,69,69),(85448,69,70),(85445,69,75),(85447,69,76),(86333,70,6),(86332,70,11),(86331,70,70),(85418,71,1),(85421,71,2),(85420,71,3),(85424,71,6),(85423,71,11),(85419,71,58),(85422,71,70),(85417,71,71),(85429,72,1),(85431,72,2),(85430,72,3),(85434,72,6),(85433,72,11),(85426,72,13),(85427,72,18),(85432,72,70),(85425,72,72),(85428,72,76),(85569,73,1),(85574,73,2),(85573,73,3),(85564,73,5),(85579,73,6),(85578,73,11),(85571,73,13),(85575,73,18),(85565,73,19),(85568,73,21),(85567,73,33),(85576,73,53),(85566,73,64),(85572,73,70),(85577,73,72),(85563,73,73),(85570,73,76),(86334,74,74),(85415,75,75),(85416,76,76),(86174,100,1),(86170,100,2),(86156,100,3),(86154,100,5),(86181,100,6),(86173,100,9),(86151,100,11),(86212,100,13),(86192,100,15),(86193,100,16),(86153,100,17),(86210,100,18),(86209,100,19),(86194,100,20),(86208,100,21),(86213,100,22),(86178,100,30),(86179,100,31),(86175,100,32),(86187,100,33),(86157,100,34),(86161,100,35),(86206,100,36),(86184,100,37),(86185,100,38),(86152,100,39),(86182,100,40),(86183,100,41),(86158,100,42),(86159,100,43),(86149,100,44),(86150,100,45),(86167,100,47),(86169,100,48),(86202,100,49),(86204,100,50),(86195,100,51),(86196,100,52),(86186,100,53),(86190,100,54),(86191,100,55),(86171,100,56),(86172,100,57),(86199,100,58),(86200,100,59),(86203,100,60),(86207,100,61),(86197,100,62),(86160,100,64),(86198,100,65),(86211,100,66),(86155,100,67),(86168,100,69),(86214,100,70),(86165,100,71),(86166,100,72),(86177,100,73),(86215,100,74),(86163,100,75),(86164,100,76),(86148,100,100),(86162,100,101),(86201,100,102),(86188,100,103),(86189,100,104),(86180,100,105),(86176,100,106),(86205,100,107),(85408,101,1),(85412,101,2),(85411,101,3),(85414,101,6),(85413,101,11),(85405,101,13),(85406,101,35),(85410,101,70),(85407,101,75),(85409,101,76),(85404,101,101),(86034,102,1),(86035,102,2),(86036,102,3),(86039,102,6),(86038,102,11),(86037,102,70),(86033,102,102),(85709,103,1),(85710,103,2),(85711,103,3),(85712,103,5),(85713,103,6),(85768,103,9),(85714,103,11),(85715,103,13),(85716,103,15),(85717,103,16),(85718,103,17),(85719,103,18),(85720,103,19),(85721,103,20),(85722,103,21),(85723,103,22),(85724,103,30),(85725,103,31),(85726,103,32),(85727,103,33),(85728,103,34),(85729,103,35),(85730,103,36),(85731,103,37),(85732,103,38),(85733,103,39),(85734,103,40),(85735,103,41),(85736,103,42),(85737,103,43),(85738,103,44),(85739,103,45),(85740,103,47),(85741,103,48),(85742,103,49),(85743,103,50),(85744,103,51),(85745,103,52),(85746,103,53),(85747,103,54),(85748,103,55),(85749,103,56),(85750,103,57),(85751,103,58),(85752,103,59),(85753,103,60),(85754,103,61),(85755,103,64),(85756,103,65),(85757,103,67),(85758,103,69),(85759,103,70),(85760,103,71),(85761,103,72),(85762,103,73),(85763,103,74),(85764,103,75),(85765,103,76),(85766,103,101),(85767,103,102),(85708,103,103),(85777,104,1),(85776,104,2),(85775,104,3),(85774,104,5),(85778,104,6),(85770,104,9),(85779,104,11),(85780,104,13),(85781,104,15),(85782,104,16),(85783,104,17),(85784,104,18),(85785,104,19),(85786,104,20),(85787,104,21),(85788,104,22),(85789,104,30),(85790,104,31),(85791,104,32),(85792,104,33),(85793,104,34),(85794,104,35),(85795,104,36),(85796,104,37),(85797,104,38),(85798,104,39),(85799,104,40),(85800,104,41),(85801,104,42),(85802,104,43),(85803,104,44),(85804,104,45),(85805,104,47),(85806,104,48),(85807,104,49),(85808,104,50),(85809,104,51),(85810,104,52),(85811,104,53),(85812,104,54),(85813,104,55),(85814,104,56),(85815,104,57),(85816,104,58),(85817,104,59),(85818,104,60),(85819,104,61),(85835,104,62),(85820,104,64),(85821,104,65),(85771,104,66),(85822,104,67),(85823,104,69),(85824,104,70),(85825,104,71),(85826,104,72),(85827,104,73),(85828,104,74),(85829,104,75),(85830,104,76),(85772,104,100),(85831,104,101),(85832,104,102),(85773,104,103),(85769,104,104),(85834,104,105),(85833,104,106),(85836,104,107),(85648,105,105),(85562,106,6),(85561,106,11),(85560,106,106),(86110,107,1),(86122,107,2),(86121,107,3),(86103,107,5),(86127,107,6),(86126,107,11),(86107,107,13),(86119,107,18),(86109,107,21),(86108,107,33),(86111,107,35),(86115,107,36),(86125,107,44),(86124,107,47),(86112,107,49),(86104,107,50),(86118,107,53),(86114,107,56),(86105,107,57),(86123,107,58),(86113,107,59),(86102,107,60),(86120,107,70),(86117,107,72),(86116,107,75),(86106,107,76),(86101,107,107);
/*!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 2022-03-14 10:27:53
+-- Dump completed on 2022-03-28 9:44:14
USE `salix`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: salix
-- ------------------------------------------------------
@@ -131,7 +131,7 @@ USE `salix`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -186,9 +186,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:27:55
+-- Dump completed on 2022-03-28 9:44:14
USE `vn`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: vn
-- ------------------------------------------------------
@@ -197,7 +197,7 @@ USE `vn`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -300,7 +300,7 @@ UNLOCK TABLES;
LOCK TABLES `claimResponsible` WRITE;
/*!40000 ALTER TABLE `claimResponsible` DISABLE KEYS */;
-INSERT INTO `claimResponsible` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0);
+INSERT INTO `claimResponsible` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0),(23,'Preparación Previa',0),(24,'Almacén PCA',0),(25,'Huelga',0);
/*!40000 ALTER TABLE `claimResponsible` ENABLE KEYS */;
UNLOCK TABLES;
@@ -310,7 +310,7 @@ UNLOCK TABLES;
LOCK TABLES `claimReason` WRITE;
/*!40000 ALTER TABLE `claimReason` DISABLE KEYS */;
-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);
+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),(47,'Seco',0),(48,'Retraso Reparto',0),(49,'Mal Embalado',0),(50,'Tumbado',0),(51,'Enfermo/Plaga',0);
/*!40000 ALTER TABLE `claimReason` ENABLE KEYS */;
UNLOCK TABLES;
@@ -330,7 +330,7 @@ UNLOCK TABLES;
LOCK TABLES `claimResult` WRITE;
/*!40000 ALTER TABLE `claimResult` DISABLE KEYS */;
-INSERT INTO `claimResult` VALUES (1,'Otros daños'),(2,'Roces'),(3,'Humedad'),(4,'Deshidratacion'),(5,'Error identidad'),(6,'Incompleto (Faltas)'),(7,'Error packing'),(8,'Error color'),(9,'Error medida'),(10,'Error origen'),(11,'Envejecido'),(12,'Venta Perdida'),(13,'Duplicacion'),(14,'Rechazado'),(15,'Rotura'),(16,'Deterioro/Estropeado'),(17,'Podrido'),(18,'Baboso'),(19,'Cocido'),(20,'Congelado'),(21,'Machacado'),(22,'Error precio'),(23,'Manchado'),(24,'No entregado'),(25,'Cobro indebido'),(26,'Decepcion/Esperaba mas'),(27,'Otros');
+INSERT INTO `claimResult` VALUES (1,'Otros daños'),(2,'Roces'),(3,'Humedad'),(4,'Deshidratacion'),(5,'Error identidad'),(6,'Incompleto (Faltas)'),(7,'Error packing'),(8,'Error color'),(9,'Error medida'),(10,'Error origen'),(11,'Envejecido'),(12,'Venta Perdida'),(13,'Duplicacion'),(14,'Rechazado'),(15,'Rotura'),(16,'Deterioro/Estropeado'),(17,'Podrido'),(18,'Baboso'),(19,'Cocido'),(20,'Congelado'),(21,'Machacado'),(22,'Error precio'),(23,'Manchado'),(24,'No entregado'),(25,'Cobro indebido'),(26,'Decepcion/Esperaba mas'),(27,'Otros'),(28,'Baboso/Cocido'),(29,'Video Camara');
/*!40000 ALTER TABLE `claimResult` ENABLE KEYS */;
UNLOCK TABLES;
@@ -350,7 +350,7 @@ UNLOCK TABLES;
LOCK TABLES `componentType` WRITE;
/*!40000 ALTER TABLE `componentType` DISABLE KEYS */;
-INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST'),(2,'com ventas',1,1,NULL),(3,'com compras',1,1,NULL),(4,'empresa',1,1,NULL),(5,'cliente',0,0,NULL),(6,'agencia',0,0,'FREIGHT'),(7,'cartera_comercial',0,0,NULL),(8,'cartera_producto',0,1,NULL),(9,'maniobra',1,0,NULL),(10,'cartera_comprador',0,1,NULL),(11,'errores',0,1,NULL),(12,'otros',0,1,NULL);
+INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST'),(2,'com ventas',1,1,NULL),(3,'com compras',1,1,NULL),(4,'empresa',1,1,'MARGIN'),(5,'cliente',0,0,NULL),(6,'agencia',0,0,'FREIGHT'),(7,'cartera_comercial',0,0,NULL),(8,'cartera_producto',0,1,NULL),(9,'maniobra',1,0,NULL),(10,'cartera_comprador',0,1,NULL),(11,'errores',0,1,NULL),(12,'otros',0,1,NULL);
/*!40000 ALTER TABLE `componentType` ENABLE KEYS */;
UNLOCK TABLES;
@@ -452,9 +452,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:28:02
+-- Dump completed on 2022-03-28 9:44:14
USE `cache`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: cache
-- ------------------------------------------------------
@@ -463,7 +463,7 @@ USE `cache`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -488,9 +488,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:28:02
+-- Dump completed on 2022-03-28 9:44:14
USE `hedera`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: hedera
-- ------------------------------------------------------
@@ -499,7 +499,7 @@ USE `hedera`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -554,9 +554,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:28:04
+-- Dump completed on 2022-03-28 9:44:14
USE `postgresql`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: postgresql
-- ------------------------------------------------------
@@ -565,7 +565,7 @@ USE `postgresql`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -640,9 +640,9 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:28:07
+-- Dump completed on 2022-03-28 9:44:14
USE `sage`;
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: sage
-- ------------------------------------------------------
@@ -651,7 +651,7 @@ USE `sage`;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -664,7 +664,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','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);
+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),(115,0,'H.P. IVA Soportado Impor 4% ',0.0000000000,4.0000000000,0.0000000000,'4722000004','','','','','','','','','','','','','','','','','',0,0);
/*!40000 ALTER TABLE `TiposIva` ENABLE KEYS */;
UNLOCK TABLES;
@@ -696,4 +696,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:28:10
+-- Dump completed on 2022-03-28 9:44:14
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index ce367a1d4..f317dd7f7 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -1,4 +1,4 @@
--- MariaDB dump 10.19 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64)
+-- MariaDB dump 10.19 Distrib 10.6.7-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: db.verdnatura.es Database: account
-- ------------------------------------------------------
@@ -2532,7 +2532,7 @@ CREATE TABLE `bancos_evolution` (
`saldo_aux` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT 'Saldo auxiliar para el calculo de lo dispuesto en las polizas',
PRIMARY KEY (`Fecha`,`Id_Banco`),
KEY `fk_banco_evolution_idx` (`Id_Banco`),
- CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ CONSTRAINT `fk_banco_evolution` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`accounting` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los saldos bancarios';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -6217,156 +6217,6 @@ BEGIN
tmp.newClients;
END IF;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `salesPersonClient_add` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `salesPersonClient_add`(intYEAR INT, vQuarter INT)
-BEGIN
-
- DECLARE vCommissionRate DOUBLE DEFAULT 0.029;
-
- DELETE s.* FROM salesPersonClient s
- JOIN vn.`time` t ON t.`year` = s.year AND t.`month` = s.month
- WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter;
-
- REPLACE salesPersonClient(salesPersonFk,clientFk, year, month, amount, comission)
- SELECT c.salesPersonFk,
- c.id,
- intYEAR,
- MONTH(v.fecha),
- SUM(v.importe),
- SUM(v.importe) * vCommissionRate
- FROM ventas v
- JOIN vn.client c on v.Id_Cliente = c.id
- JOIN vn.`time` t on t.dated = v.fecha
- WHERE c.salesPersonFk IS NOT NULL AND
- t.`year` = intYEAR AND
- QUARTER(t.dated) = vQuarter
- GROUP BY c.salesPersonFk,
- c.id,
- t.`month`;
-
- -- Ventas nuevas
- UPDATE salesPersonClient s
- JOIN (SELECT c.salesPersonFk,
- c.id,
- SUM(importe) * vCommissionRate AS comissionNewClient,
- t.`month`,
- t.`year`
- FROM ventas v
- JOIN bs.clientNewBorn cnb ON v.Id_Cliente = cnb.clientFk
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN vn.`time` t ON t.dated = v.fecha
- WHERE c.salesPersonFk IS NOT NULL AND
- t.`year` = intYEAR AND
- QUARTER(v.fecha) = vQuarter
- GROUP BY c.salesPersonFk,
- c.id,
- t.`month`
- ) sub ON sub.salesPersonFk = s.salesPersonFk AND
- sub.id = s.clientFk AND
- sub.`month` = s.month AND
- sub.`year` = s.year
- SET s.comissionNewClient = sub.comissionNewClient,
- s.comission = s.comission - sub.comissionNewClient;
-
- -- Ventas cedidas
- INSERT INTO salesPersonClient (salesPersonFk, clientFk, month, year, comissionLended)
- SELECT cc.Id_Trabajador_old AS workerFk,
- c.id,
- t.`month`,
- t.`year`,
- SUM(importe) * vCommissionRate * cc.comision_old AS comissionLended
- FROM ventas v
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN vn2008.Clientes_cedidos cc ON cc.Id_Cliente = c.id AND v.fecha BETWEEN datSTART AND datEND
- JOIN vn.`time` t ON t.dated = v.fecha
- WHERE c.salesPersonFk IS NOT NULL AND
- t.`year` = intYEAR AND
- QUARTER(v.fecha) = vQuarter
- GROUP BY cc.Id_Trabajador_old,
- c.id,
- t.`month`
- ON DUPLICATE KEY UPDATE comissionLended = IFNULL(comissionLended,0) + VALUES(comissionLended);
-
- -- Ventas arrendadas
- INSERT INTO salesPersonClient (salesPersonFk, clientFk, month, year, comissionBorrowed)
- SELECT cc.Id_Trabajador_new AS workerFk,
- c.id,
- t.`month`,
- t.`year`,
- SUM(importe) * vCommissionRate * cc.comision_new AS comissionBorrowed
- FROM ventas v
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN vn2008.Clientes_cedidos cc ON cc.Id_Cliente = c.id AND v.fecha BETWEEN datSTART AND datEND
- JOIN vn.`time` t ON t.dated = v.fecha
- WHERE c.salesPersonFk IS NOT NULL AND
- t.`year` = intYEAR AND
- QUARTER(v.fecha) = vQuarter
- GROUP BY cc.Id_Trabajador_new,
- c.id,
- t.`month`
- ON DUPLICATE KEY UPDATE comissionBorrowed = IFNULL(comissionBorrowed,0) + VALUES(comissionBorrowed);
-
- -- Actualización del campo comisión restando las comisiones arrendadas y cedidas
- UPDATE salesPersonClient s
- JOIN ( SELECT clientFk, `month`, year, SUM(comissionBorrowed) comissionBorrowed,SUM(comissionLended) comissionLended, QUARTER(CONCAT("2000-",`month`, "-01")) vQuarterMonth
- FROM salesPersonClient
- WHERE (comissionLended IS NOT NULL OR comissionBorrowed IS NOT NULL) AND
- year = intYEAR
- GROUP BY clientFk, `month`
- HAVING vQuarterMonth = vQuarter
- ) sub ON sub.clientFk = s.clientFk AND
- sub.month = s.month AND
- sub.year = s.year
- SET s.comission = s.comission - sub.comissionBorrowed - sub.comissionLended
- WHERE s.comission IS NOT NULL;
-
- -- Sustitucion cedidas - lended
- INSERT INTO salesPersonClient (salesPersonFk, clientFk, month, year, comission)
- SELECT c.salesPersonFk,
- c.id,
- t.`month`,
- t.`year`,
- SUM(importe) * vCommissionRate AS lended
- FROM ventas v
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN vn.sharingCartDaily scd ON scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha
- JOIN vn.`time` t ON t.dated = v.fecha
- WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter
- GROUP BY c.salesPersonFk,
- c.id,
- t.`month`
- ON DUPLICATE KEY UPDATE comission = comission - VALUES(comission);
-
- -- Sustitucion arrendadas - borrowed
- INSERT INTO salesPersonClient (salesPersonFk, clientFk, month, year, substitutionBorrowed)
- SELECT scd.substituteFk,
- c.id,
- t.`month`,
- t.`year`,
- SUM(importe) * vCommissionRate AS borrowed
- FROM ventas v
- JOIN vn.client c ON c.id = v.Id_Cliente
- JOIN vn.sharingCartDaily scd on scd.ownerFk = c.salesPersonFk AND scd.dated = v.fecha
- JOIN vn.`time` t ON t.dated = v.fecha
- WHERE t.`year` = intYEAR AND QUARTER(t.dated) = vQuarter
- GROUP BY scd.substituteFk, c.id, t.`month`
- ON DUPLICATE KEY UPDATE substitutionBorrowed = VALUES(substitutionBorrowed);
-
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -6566,7 +6416,6 @@ BEGIN
CALL bs.vendedores_add(YEAR(CURDATE()),QUARTER(CURDATE()));
CALL bs.vendedores_evolution_add;
- CALL bs.salesPersonClient_add(YEAR(CURDATE()), QUARTER(CURDATE()));
SELECT util.firstDayOfMonth(CURDATE())- INTERVAL 1 MONTH INTO vDatedFrom;
CALL bs.salesByclientSalesPerson_add(vDatedFrom);
@@ -13359,7 +13208,6 @@ SET character_set_client = utf8;
`isActive` tinyint NOT NULL,
`longitude` tinyint NOT NULL,
`latitude` tinyint NOT NULL,
- `warehouseFk` tinyint NOT NULL,
`agencyModeFk` tinyint NOT NULL
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
@@ -19058,7 +18906,9 @@ CREATE TABLE `bank_account` (
`bank_adress` char(125) DEFAULT NULL,
`bank_city` char(50) DEFAULT NULL,
`bank_account_link_id` int(11) DEFAULT NULL,
+ `workerFk` int(10) unsigned NOT NULL,
PRIMARY KEY (`bank_account_id`),
+ UNIQUE KEY `workerFk_UNIQUE` (`workerFk`),
KEY `fki_bank_profile` (`client_id`),
KEY `fki_business_account_fk` (`client_id`),
KEY `fki_person_account_fk` (`client_id`),
@@ -19066,7 +18916,8 @@ CREATE TABLE `bank_account` (
KEY `bank_account_nation_id` (`nation_id`),
CONSTRAINT `bank_account_bank_account_type` FOREIGN KEY (`bank_account_type_id`) REFERENCES `bank_account_type` (`bank_account_type_id`) ON UPDATE CASCADE,
CONSTRAINT `bank_account_client_id` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON UPDATE CASCADE,
- CONSTRAINT `bank_account_nation_id` FOREIGN KEY (`nation_id`) REFERENCES `vn`.`country` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `bank_account_nation_id` FOREIGN KEY (`nation_id`) REFERENCES `vn`.`country` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `bank_account_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -20276,6 +20127,458 @@ SET character_set_client = @saved_cs_client;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `accountingMovements_add`(vYear INT, vCompanyFk INT)
BEGIN
+/**
+ * Traslada la info de contabilidad generada en base a vn.XDiario a la tabla sage.movConta para poder ejecutar posteriormente el proceso de importación de datos de SQL Server
+ * Solo traladará los asientos marcados con el campo vn.XDiario.enlazadoSage = FALSE
+ * @vYear Año contable del que se quiere trasladar la información
+ * @vCompanyFk Empresa de la que se quiere trasladar datos
+ */
+ DECLARE vDatedFrom DATETIME;
+ DECLARE vDatedTo DATETIME;
+ DECLARE vDuaTransactionFk INT;
+ DECLARE vTaxImportFk INT;
+ DECLARE vTaxImportReducedFk INT;
+ DECLARE vTaxImportSuperReducedFk INT;
+ DECLARE vTransactionExportFk INT;
+ DECLARE vTransactionExportTaxFreeFk INT;
+ DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
+ DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
+ DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ;
+ DECLARE vBookEntries TEXT;
+
+ SELECT SiglaNacion INTO vCountryCanariasCode
+ FROM Naciones
+ WHERE Nacion ='ISLAS CANARIAS';
+
+ SELECT SiglaNacion INTO vCountryCeutaMelillaCode
+ FROM Naciones
+ WHERE Nacion ='CEUTA Y MELILLA';
+
+ SELECT CodigoTransaccion INTO vDuaTransactionFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Import. bienes y serv. corrientes pdte. liquidar';
+
+ SELECT CodigoIva INTO vTaxImportFk
+ FROM TiposIva
+ WHERE Iva = 'IVA 21% importaciones';
+
+ SELECT CodigoIva INTO vTaxImportReducedFk
+ FROM TiposIva
+ WHERE Iva = 'IVA 10% importaciones';
+
+ SELECT CodigoIva INTO vTaxImportSuperReducedFk
+ FROM TiposIva
+ WHERE Iva = 'H.P. IVA Soportado Impor 4%';
+
+ SELECT CodigoTransaccion INTO vTransactionExportFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Exportaciones definitivas';
+
+ SELECT CodigoTransaccion INTO vTransactionExportTaxFreeFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Envíos definitivos a Canarias, Ceuta y Melilla';
+
+ SELECT codeSage INTO vInvoiceTypeInformativeCode
+ FROM invoiceType WHERE code ='informative';
+
+ SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE))
+ INTO vDatedFrom, vDatedTo;
+
+ TRUNCATE movContaIVA;
+
+ DELETE FROM movConta
+ WHERE enlazadoSage = FALSE
+ AND Asiento <> 1 ;
+
+ CALL clientSupplier_add(vCompanyFk);
+ CALL pgc_add(vCompanyFk);
+ CALL invoiceOut_manager(vYear, vCompanyFk);
+ CALL invoiceIn_manager(vYear, vCompanyFk);
+
+ INSERT INTO movConta(TipoEntrada,
+ Ejercicio,
+ CodigoEmpresa,
+ Asiento,
+ CargoAbono,
+ CodigoCuenta,
+ Contrapartida,
+ FechaAsiento,
+ Comentario,
+ ImporteAsiento,
+ NumeroPeriodo,
+ FechaGrabacion,
+ CodigoDivisa,
+ ImporteCambio,
+ ImporteDivisa,
+ FactorCambio,
+ IdProcesoIME,
+ TipoCarteraIME,
+ TipoAnaliticaIME,
+ StatusTraspasadoIME,
+ TipoImportacionIME,
+ Metalico347,
+ BaseIva1,
+ PorBaseCorrectora1,
+ PorIva1,
+ CuotaIva1,
+ PorRecargoEquivalencia1,
+ RecargoEquivalencia1,
+ CodigoTransaccion1,
+ BaseIva2,
+ PorBaseCorrectora2,
+ PorIva2,
+ CuotaIva2,
+ PorRecargoEquivalencia2,
+ RecargoEquivalencia2,
+ CodigoTransaccion2,
+ BaseIva3,
+ PorBaseCorrectora3,
+ PorIva3,
+ CuotaIva3,
+ PorRecargoEquivalencia3,
+ RecargoEquivalencia3,
+ CodigoTransaccion3,
+ BaseIva4,
+ PorBaseCorrectora4,
+ PorIva4,
+ CuotaIva4,
+ PorRecargoEquivalencia4,
+ RecargoEquivalencia4,
+ CodigoTransaccion4,
+ Año,
+ Serie,
+ Factura,
+ SuFacturaNo,
+ FechaFactura,
+ ImporteFactura,
+ TipoFactura,
+ CodigoCuentaFactura,
+ CifDni,
+ Nombre,
+ CodigoRetencion,
+ BaseRetencion,
+ PorRetencion,
+ ImporteRetencion,
+ SiglaNacion,
+ EjercicioFactura,
+ FechaOperacion,
+ Exclusion347,
+ MantenerAsiento,
+ ClaveOperacionFactura_,
+ TipoRectificativa,
+ FechaFacturaOriginal,
+ BaseImponibleOriginal,
+ CuotaIvaOriginal,
+ ClaseAbonoRectificativas,
+ RecargoEquivalenciaOriginal,
+ LibreA1,
+ CodigoIva1,
+ CodigoIva2,
+ CodigoIva3,
+ CodigoIva4,
+ IvaDeducible1,
+ IvaDeducible2,
+ IvaDeducible3,
+ IvaDeducible4,
+ Intracomunitaria
+ )
+ SELECT 'EN' TipoEntrada,
+ YEAR(x.FECHA) Ejercicio,
+ IF (@@hostname = 'db', c.companyCode, companyCodeTest) AS CodigoEmpresa,
+ x.ASIEN Asiento,
+ IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono,
+ x.SUBCTA CodigoCuenta,
+ x.CONTRA Contrapartida,
+ x.FECHA FechaAsiento,
+ x.CONCEPTO Comentario,
+ IF(x.EURODEBE, x.EURODEBE, x.EUROHABER) ImporteAsiento,
+ MONTH(x.FECHA) NumeroPeriodo,
+ IF(sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion,
+ IF(x.CAMBIO, IFNULL(mci.CodigoDivisa, sub3.code), '') CodigoDivisa,
+ x.CAMBIO ImporteCambio,
+ IFNULL(x.DEBEME, x.HABERME) ImporteDivisa,
+ IF(x.CAMBIO, TRUE, FALSE) FactorCambio,
+ NULL IdProcesoIME,
+ 0 TipoCarteraIME,
+ 0 TipoAnaliticaIME,
+ 0 StatusTraspasadoIME,
+ 0 TipoImportacionIME,
+ x.METAL Metalico347,
+ mci.BaseIva1,
+ mci.PorBaseCorrectora1,
+ mci.PorIva1,
+ mci.CuotaIva1,
+ mci.PorRecargoEquivalencia1,
+ mci.RecargoEquivalencia1,
+ mci.CodigoTransaccion1,
+ mci.BaseIva2,
+ mci.PorBaseCorrectora2,
+ mci.PorIva2,
+ mci.CuotaIva2,
+ mci.PorRecargoEquivalencia2,
+ mci.RecargoEquivalencia2,
+ mci.CodigoTransaccion2,
+ mci.BaseIva3,
+ mci.PorBaseCorrectora3,
+ mci.PorIva3,
+ mci.CuotaIva3,
+ mci.PorRecargoEquivalencia3,
+ mci.RecargoEquivalencia3,
+ mci.CodigoTransaccion3,
+ mci.BaseIva4,
+ mci.PorBaseCorrectora4,
+ mci.PorIva4,
+ mci.CuotaIva4,
+ mci.PorRecargoEquivalencia4,
+ mci.RecargoEquivalencia4,
+ mci.CodigoTransaccion4,
+ mci.Año,
+ mci.Serie,
+ mci.Factura,
+ mci.SuFacturaNo,
+ mci.FechaFactura,
+ mci.ImporteFactura,
+ mci.TipoFactura,
+ mci.CodigoCuentaFactura,
+ mci.CifDni,
+ mci.Nombre,
+ mci.CodigoRetencion,
+ mci.BaseRetencion,
+ mci.PorRetencion,
+ mci.ImporteRetencion,
+ mci.SiglaNacion,
+ mci.EjercicioFactura,
+ mci.FechaOperacion,
+ mci.Exclusion347,
+ TRUE,
+ mci.ClaveOperacionFactura,
+ mci.TipoRectificativa,
+ mci.FechaFacturaOriginal,
+ mci.BaseImponibleOriginal,
+ mci.CuotaIvaOriginal,
+ mci.ClaseAbonoRectificativas,
+ mci.RecargoEquivalenciaOriginal,
+ mci.LibreA1,
+ mci.CodigoIva1,
+ mci.CodigoIva2,
+ mci.CodigoIva3,
+ mci.CodigoIva4,
+ mci.IvaDeducible1,
+ mci.IvaDeducible2,
+ mci.IvaDeducible3,
+ mci.IvaDeducible4,
+ mci.Intracomunitaria
+ FROM vn.XDiario x
+ JOIN vn.company c ON c.id = x.empresa_id
+ LEFT JOIN movContaIVA mci ON mci.id = x.id
+ LEFT JOIN (SELECT *
+ FROM (SELECT DISTINCT ASIEN, FECREGCON, FECHA_EX
+ FROM vn.XDiario
+ WHERE enlazadoSage = FALSE
+ 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
+ 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 x.enlazadoSage = FALSE
+ AND x.empresa_id = vCompanyFk
+ AND x.FECHA BETWEEN vDatedFrom AND vDatedTo;
+
+-- Metálicos
+ UPDATE movConta m
+ JOIN (SELECT Asiento,
+ c.socialName name,
+ c.fi,
+ n.SiglaNacion,
+ m.CodigoCuenta,
+ m.Contrapartida
+ FROM movConta m
+ LEFT JOIN vn.client c ON c.id = IF(m.CargoAbono = 'H',
+ CAST(SUBSTRING(m.CodigoCuenta, 3, LENGTH(m.CodigoCuenta)) AS UNSIGNED),
+ CAST(SUBSTRING(m.Contrapartida, 3, LENGTH(m.Contrapartida)) AS UNSIGNED))
+ LEFT JOIN Naciones n ON n.countryFk = c.countryFk
+ WHERE m.Metalico347 = TRUE
+ AND m.enlazadoSage = FALSE
+ )sub ON m.Asiento = sub.Asiento
+ SET m.Metalico347 = TRUE,
+ m.TipoFactura = vInvoiceTypeInformativeCode,
+ m.CifDni = sub.fi,
+ m.Nombre = sub.name,
+ m.SiglaNacion = sub.SiglaNacion
+ WHERE m.enlazadoSage = FALSE;
+
+ UPDATE movConta m
+ SET m.Metalico347 = FALSE,
+ m.TipoFactura = ''
+ WHERE m.CargoAbono = 'D'
+ AND m.enlazadoSage = FALSE;
+
+-- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación
+ DELETE cp
+ FROM clientesProveedores cp
+ LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta
+ AND mc.enlazadoSage = FALSE
+ WHERE mc.codigoCuenta IS NULL;
+
+-- Elimina cuentas contables que no se utilizarán en la importación
+ DELETE pc
+ FROM planCuentasPGC pc
+ LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta
+ AND mc.enlazadoSage = FALSE
+ WHERE mc.codigoCuenta IS NULL;
+
+-- DUAS
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci
+ SET mci.BaseIva1 = x.BASEEURO,
+ mci.PorIva1 = x.IVA,
+ mci.CuotaIva1 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)),
+ mci.CodigoTransaccion1 = vDuaTransactionFk,
+ mci.CodigoIva1 = vTaxImportReducedFk,
+ mci.IvaDeducible1 = TRUE,
+ mci.FechaFacturaOriginal = x.FECHA_EX,
+ mci.SuFacturaNo = x.FACTURAEX,
+ mci.FechaOperacion = x.FECHA_OP,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8_general_ci
+ AND ti.Iva = 'I.V.A. 10% Nacional';
+
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci
+ SET mci.BaseIva2 = x.BASEEURO ,
+ mci.PorIva2 = x.IVA,
+ mci.CuotaIva2 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)),
+ mci.CodigoTransaccion2 = vDuaTransactionFk ,
+ mci.CodigoIva2 = vTaxImportFk,
+ mci.IvaDeducible2 = TRUE,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8_general_ci
+ AND ti.Iva = 'I.V.A. 21%';
+
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8_general_ci
+ SET mci.BaseIva3 = x.BASEEURO ,
+ mci.PorIva3 = x.IVA,
+ mci.CuotaIva3 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)),
+ mci.CodigoTransaccion3 = vDuaTransactionFk ,
+ mci.CodigoIva3 = vTaxImportSuperReducedFk,
+ mci.IvaDeducible3 = TRUE,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8_general_ci
+ AND ti.Iva = 'I.V.A. 4%';
+
+-- Rectificativas
+ UPDATE movConta mci
+ JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT
+ FROM movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ WHERE mci.TipoRectificativa > 0
+ AND mci.enlazadoSage = FALSE
+ AND x.FACTU_RT IS NOT NULL
+ GROUP BY x.ASIEN
+ ) sub ON sub.ASIEN = mci.Asiento
+ SET mci.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT),
+ mci.SerieFacturaOriginal = sub.SERIE_RT,
+ mci.NumeroFacturaOriginal = sub.FACTU_RT
+ WHERE mci.TipoRectificativa > 0 AND
+ mci.enlazadoSage = FALSE ;
+
+-- Exportaciones Andorras y Canarias cambia TT (la cuenta es compartida)
+ UPDATE movConta mci
+ SET CodigoTransaccion1 = vTransactionExportTaxFreeFk,
+ CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, vTransactionExportTaxFreeFk),
+ CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, vTransactionExportTaxFreeFk),
+ CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, vTransactionExportTaxFreeFk)
+ WHERE enlazadoSage = FALSE
+ AND (CodigoTransaccion1 = vTransactionExportFk
+ OR CodigoTransaccion2 = vTransactionExportFk
+ OR CodigoTransaccion3 = vTransactionExportFk
+ OR CodigoTransaccion4 = vTransactionExportFk)
+ AND SiglaNacion IN (vCountryCanariasCode COLLATE utf8_general_ci, vCountryCeutaMelillaCode COLLATE utf8_general_ci);
+
+ UPDATE movConta mc
+ SET CodigoDivisa = 'USD',
+ FactorCambio = TRUE,
+ ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio = 0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2)))
+ WHERE enlazadoSage = FALSE
+ AND (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio);
+
+ UPDATE movConta mc
+ SET importeDivisa= -importeDivisa
+ WHERE enlazadoSage = FALSE
+ AND importeDivisa > 0
+ AND ImporteAsiento < 0;
+
+ -- Comprobación que los importes e ivas sean correctos, avisa vía CAU
+ SELECT GROUP_CONCAT(Asiento ORDER BY Asiento ASC SEPARATOR ' \n\r') INTO vBookEntries
+ FROM(SELECT sub.Asiento
+ FROM (SELECT mc.Asiento, SUM(mc.ImporteAsiento) amount
+ FROM movConta mc
+ WHERE mc.enlazadoSage = FALSE
+ GROUP BY mc.Asiento)sub
+ JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount
+ FROM vn.XDiario x
+ WHERE x.enlazadoSage = FALSE
+ GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amount <> sub2.amount
+ UNION ALL
+ SELECT sub.Asiento
+ FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase
+ FROM movConta
+ WHERE TipoFactura <> 'I'
+ AND enlazadoSage = FALSE
+ GROUP BY Asiento) sub
+ JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase
+ FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO
+ FROM vn.XDiario
+ WHERE FACTURA
+ AND auxiliar <> '*'
+ AND enlazadoSage = FALSE
+ GROUP BY FACTURA, ASIEN)sub3
+ GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amountTaxableBase<>sub2.amountTaxableBase
+ AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase) sub;
+
+ IF vBookEntries IS NOT NULL THEN
+ CALL vn.mail_insert('cau@verdnatura.es, administracion@verdnatura.es',
+ 'noreply@verdnatura.es',
+ CONCAT('Asientos contables importados incorrectamente'),
+ CONCAT('
Existen asientos que difieren entre la info. de XDiario y la que se ha importado a Sage.
+ Asientos nº ', vBookEntries, ''));
+ END IF;
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `accountingMovements_add__` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `accountingMovements_add__`(vYear INT, vCompanyFk INT)
+BEGIN
/**
* Traslada la info de contabilidad generada en base a vn.XDiario a la tabla sage.movConta para poder ejecutar posteriormente el proceso de importación de datos de SQL Server
* Solo traladará los asientos marcados con el campo vn.XDiario.enlazadoSage = FALSE
@@ -26112,23 +26415,30 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Temporary table structure for view `accounting`
+-- Table structure for table `accounting`
--
DROP TABLE IF EXISTS `accounting`;
-/*!50001 DROP VIEW IF EXISTS `accounting`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `accounting` (
- `id` tinyint NOT NULL,
- `bank` tinyint NOT NULL,
- `account` tinyint NOT NULL,
- `accountingTypeFk` tinyint NOT NULL,
- `entityFk` tinyint NOT NULL,
- `isActive` tinyint NOT NULL,
- `currencyFk` 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 `accounting` (
+ `id` int(11) NOT NULL DEFAULT '0',
+ `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `account` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
+ `accountingTypeFk` smallint(6) NOT NULL DEFAULT '0',
+ `entityFk` int(10) unsigned NOT NULL,
+ `isActive` tinyint(4) NOT NULL DEFAULT '1',
+ `currencyFk` tinyint(3) unsigned DEFAULT '1',
+ `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `BancosBanco` (`bank`),
+ KEY `fk_Bancos_entity1_idx` (`entityFk`),
+ KEY `foreignkey1_idx` (`accountingTypeFk`),
+ KEY `Bancoscurrency_idx` (`currencyFk`),
+ CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `bank_FK` FOREIGN KEY (`accountingTypeFk`) REFERENCES `accountingType` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType';
+/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `accountingType`
@@ -26190,7 +26500,7 @@ DROP TABLE IF EXISTS `address`;
CREATE TABLE `address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`clientFk` int(11) NOT NULL DEFAULT '0',
- `warehouseFk` smallint(6) unsigned DEFAULT '1',
+ `warehouseFk__` smallint(6) unsigned DEFAULT '1',
`street` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`city` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`provinceFk` smallint(5) unsigned DEFAULT NULL,
@@ -26216,7 +26526,7 @@ CREATE TABLE `address` (
PRIMARY KEY (`id`),
KEY `Id_Agencia` (`agencyModeFk`),
KEY `Id_cliente` (`clientFk`),
- KEY `warehouse_id` (`warehouseFk`),
+ KEY `warehouse_id` (`warehouseFk__`),
KEY `province_id` (`provinceFk`),
KEY `telefono` (`phone`),
KEY `movil` (`mobile`),
@@ -26225,7 +26535,7 @@ CREATE TABLE `address` (
KEY `address_incotermsFk_idx` (`incotermsFk`),
CONSTRAINT `address_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_customsAgentFk` FOREIGN KEY (`customsAgentFk`) REFERENCES `customsAgent` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk__`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE
@@ -26429,7 +26739,7 @@ CREATE TABLE `agency` (
KEY `agency_ibfk_3_idx` (`workCenterFk`),
KEY `agency_ibfk_4_idx` (`supplierFk`),
CONSTRAINT `agency_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `agency_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `agency_ibfk_3` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE,
CONSTRAINT `agency_ibfk_4` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -26882,30 +27192,24 @@ SET character_set_client = utf8;
SET character_set_client = @saved_cs_client;
--
--- Table structure for table `bank`
+-- Temporary table structure for view `bank`
--
DROP TABLE IF EXISTS `bank`;
-/*!40101 SET @saved_cs_client = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `bank` (
- `id` int(11) NOT NULL DEFAULT '0',
- `bank` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- `account` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
- `cash` smallint(6) NOT NULL DEFAULT '0',
- `entityFk` int(10) unsigned NOT NULL,
- `isActive` tinyint(4) NOT NULL DEFAULT '1',
- `currencyFk` tinyint(3) unsigned DEFAULT '1',
- `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
- PRIMARY KEY (`id`),
- KEY `BancosBanco` (`bank`),
- KEY `fk_Bancos_entity1_idx` (`entityFk`),
- KEY `foreignkey1_idx` (`cash`),
- KEY `Bancoscurrency_idx` (`currencyFk`),
- CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `bank_FK` FOREIGN KEY (`cash`) REFERENCES `accountingType` (`id`) ON UPDATE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType';
-/*!40101 SET character_set_client = @saved_cs_client */;
+/*!50001 DROP VIEW IF EXISTS `bank`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `bank` (
+ `id` tinyint NOT NULL,
+ `bank` tinyint NOT NULL,
+ `account` tinyint NOT NULL,
+ `cash` tinyint NOT NULL,
+ `entityFk` tinyint NOT NULL,
+ `isActive` tinyint NOT NULL,
+ `currencyFk` tinyint NOT NULL,
+ `code` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
--
-- Table structure for table `bankEntity`
@@ -28247,9 +28551,6 @@ BEGIN
) > 0 THEN
CALL util.throw("HAS_CLIENT_PROTECTED");
END IF;
- UPDATE vn2008.Clientes_cedidos
- SET datEND = CURDATE()
- WHERE Id_Cliente = NEW.id;
END IF;
SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk);
@@ -32425,7 +32726,7 @@ CREATE TABLE `host` (
CONSTRAINT `configHost_FK_1` FOREIGN KEY (`itemPackingTypeFk`) REFERENCES `itemPackingType` (`code`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `configHost_FK_4` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `configHost_FK_4` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `configHost_FK_5` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32878,7 +33179,7 @@ CREATE TABLE `invoiceInDueDay` (
PRIMARY KEY (`id`),
KEY `recibida_id` (`invoiceInFk`),
KEY `banco_id` (`bankFk`),
- CONSTRAINT `invoiceInDueDay_ibfk_6` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `invoiceInDueDay_ibfk_6` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `invoiceInDueDay_ibfk_7` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -32990,32 +33291,63 @@ DROP TABLE IF EXISTS `invoiceInIntrastat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `invoiceInIntrastat` (
+ `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
+ `invoiceInFk` mediumint(8) unsigned NOT NULL,
+ `net` decimal(10,2) DEFAULT NULL,
+ `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06049190',
+ `amount` double NOT NULL,
+ `stems` int(11) NOT NULL,
+ `countryFk` mediumint(8) unsigned DEFAULT NULL,
+ `dated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `statisticalValue` double NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`),
+ KEY `intrastat_id` (`intrastatFk`),
+ KEY `invoiceInIntrastat_FK` (`invoiceInFk`),
+ CONSTRAINT `invoiceInIntrastat_FK` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`),
+ CONSTRAINT `invoiceInIntrastat_ibfk_1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Temporary table structure for view `invoiceInIntrastat2__`
+--
+
+DROP TABLE IF EXISTS `invoiceInIntrastat2__`;
+/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat2__`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `invoiceInIntrastat2__` (
+ `id` tinyint NOT NULL,
+ `invoiceInFk` tinyint NOT NULL,
+ `net` tinyint NOT NULL,
+ `intrastatFk` tinyint NOT NULL,
+ `amount` tinyint NOT NULL,
+ `stems` tinyint NOT NULL,
+ `countryFk` tinyint NOT NULL,
+ `dated` tinyint NOT NULL,
+ `statisticalValue` tinyint NOT NULL
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Table structure for table `invoiceInIntrastat__`
+--
+
+DROP TABLE IF EXISTS `invoiceInIntrastat__`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `invoiceInIntrastat__` (
`invoiceInFk` mediumint(8) unsigned NOT NULL,
`intrastatFk` int(8) unsigned zerofill NOT NULL,
`amount` decimal(10,2) NOT NULL,
PRIMARY KEY (`invoiceInFk`,`intrastatFk`),
KEY `Codintrastat` (`intrastatFk`),
KEY `recibida_id` (`invoiceInFk`),
- CONSTRAINT `invoiceInIntrastat_ibfk_1` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `invoiceInIntrastat_ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `invoiceInIntrastat___ibfk_1` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `invoiceInIntrastat___ibfk_2` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
---
--- Temporary table structure for view `invoiceInIntrastat__`
---
-
-DROP TABLE IF EXISTS `invoiceInIntrastat__`;
-/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat__`*/;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
-/*!50001 CREATE TABLE `invoiceInIntrastat__` (
- `invoiceInFk` tinyint NOT NULL,
- `intrastatFk` tinyint NOT NULL,
- `amount` tinyint NOT NULL
-) ENGINE=MyISAM */;
-SET character_set_client = @saved_cs_client;
-
--
-- Table structure for table `invoiceInLog`
--
@@ -33234,7 +33566,7 @@ CREATE TABLE `invoiceOut` (
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_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`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;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -33472,7 +33804,7 @@ CREATE TABLE `item` (
`doPhoto` tinyint(4) NOT NULL DEFAULT '0',
`image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
- `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
+ `niche__` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010',
`hasMinPrice` tinyint(1) NOT NULL DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -36391,7 +36723,7 @@ CREATE TABLE `payment` (
CONSTRAINT `pago_pay_met` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE,
CONSTRAINT `payment_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`),
CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `payment_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `payment_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) 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 */ ;
@@ -37492,7 +37824,7 @@ CREATE TABLE `propertyNotes` (
KEY `propertyNotes_FK` (`propertyFk`),
CONSTRAINT `propertyNotes_FK` FOREIGN KEY (`propertyFk`) REFERENCES `account`.`user` (`id`),
CONSTRAINT `propertyNotes_FK_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -37780,7 +38112,7 @@ CREATE TABLE `receipt` (
KEY `payed` (`payed`),
CONSTRAINT `receiptWorkerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -39790,7 +40122,7 @@ CREATE TABLE `sinisterDetail` (
KEY `sinisterDetail_fk3_idx` (`bankFk`),
CONSTRAINT `sinisterDetail_fk1` FOREIGN KEY (`sinisterFk`) REFERENCES `sinister` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `sinisterDetail_fk2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE,
- CONSTRAINT `sinisterDetail_fk3` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE
+ CONSTRAINT `sinisterDetail_fk3` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -40286,6 +40618,38 @@ CREATE TABLE `supplierAccount` (
KEY `fk_banco_prov_account_idx` (`bankFk`)
) 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`@`localhost`*/ /*!50003 TRIGGER supplierAccount_afterUpdate
+ AFTER UPDATE ON supplierAccount
+ FOR EACH ROW
+BEGIN
+ DECLARE vPayMethodHasVerified BOOL;
+
+ SELECT pm.hasVerified INTO vPayMethodHasVerified
+ FROM vn.supplier s
+ JOIN vn.payMethod pm ON pm.id = s.payMethodFk
+ WHERE s.id = OLD.supplierFk;
+
+ IF OLD.iban <> NEW.iban OR OLD.bankEntityFk <> NEW.bankEntityFk AND vPayMethodHasVerified THEN
+ UPDATE vn.supplier
+ SET isPayMethodChecked = FALSE
+ WHERE id = OLD.supplierFk;
+ END IF;
+
+END */;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `supplierActivity`
@@ -41863,7 +42227,7 @@ CREATE TABLE `till` (
KEY `empresa_id` (`companyFk`),
KEY `warehouse_id` (`warehouseFk`),
KEY `fk_Cajas_Proveedores_account1_idx` (`supplierAccountFk`),
- CONSTRAINT `till_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `till_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE,
CONSTRAINT `till_ibfk_3` 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 */;
@@ -42337,6 +42701,40 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+--
+-- Table structure for table `travelClonedWeekly`
+--
+
+DROP TABLE IF EXISTS `travelClonedWeekly`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `travelClonedWeekly` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `weekStart` tinyint(3) unsigned NOT NULL,
+ `weekEnd` tinyint(3) unsigned NOT NULL,
+ `warehouseOutFk` smallint(6) unsigned NOT NULL,
+ `warehouseInFk` smallint(6) unsigned NOT NULL,
+ `agencyModeFk` int(11) NOT NULL,
+ `weekDay` tinyint(3) unsigned NOT NULL,
+ `duration` tinyint(3) unsigned NOT NULL,
+ `ref` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
+ `supplierFk` int(11) DEFAULT NULL,
+ `kg` decimal(10,0) unsigned DEFAULT NULL,
+ `travelFk` int(11) unsigned DEFAULT NULL COMMENT 'Travel origen para clonar ademas sus entradas',
+ PRIMARY KEY (`id`),
+ KEY `travelClonedWeekly_FK` (`warehouseOutFk`),
+ KEY `travelClonedWeekly_FK_1` (`warehouseInFk`),
+ KEY `travelClonedWeekly_FK_2` (`agencyModeFk`),
+ KEY `travelClonedWeekly_FK_3` (`supplierFk`),
+ KEY `travelClonedWeekly_FK_4` (`travelFk`),
+ CONSTRAINT `travelClonedWeekly_FK` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travelClonedWeekly_FK_1` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travelClonedWeekly_FK_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `travelClonedWeekly_FK_3` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `travelClonedWeekly_FK_4` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE
+) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `travelLog`
--
@@ -46573,23 +46971,36 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` FUNCTION `getNextDueDate`(datFecha DATE,intDia INT,intPayDay INT) RETURNS date
+CREATE DEFINER=`root`@`localhost` FUNCTION `getNextDueDate`(vDated DATE, vGapDays INT, vPayDay INT) RETURNS date
NO SQL
BEGIN
- DECLARE n DATE;
- DECLARE datVenc DATE;
- DECLARE intVenc INT;
+ DECLARE vReturn DATE;
+ DECLARE vDuaDate DATE;
+ DECLARE vDuaDateDay INT;
+
+ SELECT TIMESTAMPADD(DAY, vGapDays, vDated) INTO vDuaDate;
- SELECT TIMESTAMPADD(DAY,intDia,datFecha) INTO datVenc;
- SELECT DAY(datVenc) INTO intVenc;
- SELECT MIN(TIMESTAMPADD(MONTH,(intVenc > intPayDay),DATE_FORMAT(datVenc,CONCAT('%y/%m/',intPayDay)))) INTO n;
+ IF vDuaDate = CONCAT(YEAR(vDuaDate), '-03-01') THEN
+ SET vDuaDate = TIMESTAMPADD (DAY , -1, vDuaDate);
+ ELSEIF vDuaDate = CONCAT(YEAR(vDuaDate), '-02-29') THEN
+ SET vDuaDate = TIMESTAMPADD (DAY , -2, vDuaDate);
+ END IF;
- RETURN n;
+ IF MONTH(vDuaDate) = 2 AND vPayDay = 30 THEN
+ IF util.isLeapYear(YEAR(vDuaDate)) THEN
+ SET vPayDay = 29;
+ ELSE
+ SET vPayDay = 28;
+ END IF;
+ END IF;
+
+ SELECT DAY(vDuaDate) INTO vDuaDateDay;
+ RETURN TIMESTAMPADD(MONTH, (vDuaDateDay > vPayDay), DATE_FORMAT(vDuaDate, CONCAT('%y/%m/', vPayDay)));
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -46903,6 +47314,7 @@ BEGIN
WHERE `name` = userName;
RETURN vUser;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -53064,11 +53476,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `clean`()
BEGIN
@@ -53076,18 +53488,18 @@ BEGIN
DECLARE vOneYearAgo DATE;
DECLARE vFourYearsAgo DATE;
DECLARE v18Month DATE;
- DECLARE v26Month DATE;
- DECLARE v3Month DATE;
- DECLARE vTrashId varchar(15);
-
+ DECLARE v26Month DATE;
+ DECLARE v3Month DATE;
+ DECLARE vTrashId varchar(15);
+
SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE());
SET vOneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE());
SET vFourYearsAgo = TIMESTAMPADD(YEAR,-4,CURDATE());
- SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
+ SET v18Month = TIMESTAMPADD(MONTH, -18,CURDATE());
SET v26Month = TIMESTAMPADD(MONTH, -26,CURDATE());
- SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
-
- DELETE FROM ticketParking WHERE created < vDateShort;
+ SET v3Month = TIMESTAMPADD(MONTH, -3, CURDATE());
+
+ DELETE FROM ticketParking WHERE created < vDateShort;
DELETE FROM routesMonitor WHERE dated < vDateShort;
DELETE FROM workerTimeControlLog WHERE created < vDateShort;
DELETE FROM `message` WHERE sendDate < vDateShort;
@@ -53099,7 +53511,7 @@ BEGIN
DELETE FROM entryLog WHERE creationDate < vDateShort;
DELETE IGNORE FROM expedition WHERE created < v26Month;
DELETE FROM sms WHERE created < v18Month;
- DELETE FROM saleTracking WHERE created < vDateShort;
+ DELETE FROM saleTracking WHERE created < vOneYearAgo;
DELETE tobs FROM ticketObservation tobs
JOIN ticket t ON tobs.ticketFk = t.id WHERE t.shipped < TIMESTAMPADD(YEAR,-2,CURDATE());
DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < vOneYearAgo;
@@ -55686,11 +56098,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_newWithWagon`(vSectorFk INT, vWagons INT)
proc:BEGIN
@@ -55731,9 +56143,9 @@ proc:BEGIN
SELECT isPreviousPrepared, warehouseFk, itemPackingTypeFk
INTO vIsPreviousPrepared, vWarehouseFk, vItemPackingTypeFk
FROM vn.sector
- WHERE id = vSectorFk;
+ WHERE id = vSectorFk; -- Hola
--- Si está habilitado el modo cazador para las motos, y el usuario no está registrado, se sale.
+-- Si está habilitado el modo cazador para las motos, y el usuario no esta registrado, se sale.
IF (SELECT isTractorHuntingMode FROM vn.deviceProductionConfig dpc) AND vItemPackingTypeFk = 'H' THEN
IF (SELECT COUNT(*) FROM vn.workerWithoutTractor wwt WHERE wwt.workerFk = account.userGetId()) THEN
@@ -55756,14 +56168,10 @@ proc:BEGIN
END IF;
- -- SET vMaxTicketPrinted = 8 * vWagons;
- -- SET vMaxTickets = 4 * vWagons;
SELECT ticketPrintedMax * vWagons, ticketTrolleyMax * vWagons
INTO vMaxTicketPrinted, vMaxTickets
FROM vn.productionConfig pc;
- CALL util.debugAdd('cnww:',CONCAT(vMaxTicketPrinted, vMaxTickets));
-
IF vIsPreviousPrepared THEN
LEAVE proc; -- Hasta que tengamos el altillo, vamos a cancelar esta opcion
@@ -55801,24 +56209,23 @@ proc:BEGIN
SELECT LAST_INSERT_ID() INTO vCollectionFk;
-
-- 05/08/2021 PAK Jose Frau pide que los tickets de recogida en Algemesí sólo se saquen si están asignados.
DELETE pb.*
- FROM tmp.productionBuffer pb
- JOIN vn.state s ON s.id = pb.state
- WHERE pb.agency = 'REC_ALGEMESI'
- AND s.code != 'PICKER_DESIGNED';
-
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
+ WHERE pb.agency = 'REC_ALGEMESI'
+ AND s.code != 'PICKER_DESIGNED';
+
-- 2/3/2022 PAK Se acuerda con Pepe que los pedidos con riesgo no se sacan aunque se asignen.
DELETE pb.*
FROM tmp.productionBuffer pb
WHERE pb.problem LIKE '%RIESGO%';
- -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets
- -- y los sacamos independientemente de problemas o tamaños
- SELECT COUNT(*) INTO hasAssignedTickets
- FROM tmp.productionBuffer pb
- JOIN vn.state s ON s.id = pb.state
+ -- Comprobamos si hay tickets asignados. En ese caso, nos centramos exclusivamente en esos tickets
+ -- y los sacamos independientemente de problemas o tamaños
+ SELECT COUNT(*) INTO hasAssignedTickets
+ FROM tmp.productionBuffer pb
+ JOIN vn.state s ON s.id = pb.state
WHERE s.code = 'PICKER_DESIGNED'
AND pb.workerCode = vWorkerCode;
@@ -55839,7 +56246,7 @@ proc:BEGIN
mm,
s.`order` DESC,
pb.m3 DESC;
-
+
WHILE (SELECT COUNT(*) FROM tmp.ticketToSplit) DO
SELECT MIN(ticketFk) INTO vTicketToSplit
@@ -55863,24 +56270,27 @@ proc:BEGIN
ELSE
- SELECT COUNT(*) INTO vPrintedTickets
+ SELECT COUNT(*) INTO vPrintedTickets
FROM tmp.productionBuffer pb
JOIN vn.state s ON s.id = pb.state
JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
JOIN vn.agency a ON a.id = am.agencyFk
JOIN vn.productionConfig pc
WHERE pb.shipped = CURDATE()
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
AND s.isPreparable
- AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)
- OR pb.N > 0 AND ISNULL(pb.collectionH))
- AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE);
-
+ AND (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE);
+
SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets;
- -- AutoPRINT
-
- -- IF vMaxTicketPrinted > 0 THEN
+
+ -- AutoPRINT
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
SELECT s2.id, pb.ticketFk, vn.getUser()
@@ -55893,41 +56303,49 @@ proc:BEGIN
JOIN vn.ticketConfig tc
JOIN vn.productionConfig pc
WHERE pb.shipped = CURDATE()
- AND (LENGTH(pb.problem) = 0 OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2))
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
+ AND (LENGTH(pb.problem) = 0
+ OR (pb.problem = 'PEQUEÑO' AND vTrainFk = 2))
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
AND s.isPrintable
AND s.isOK
- AND (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV)
- OR pb.N > 0 AND ISNULL(pb.collectionH))
+ AND (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
AND t.created < TIMESTAMPADD(MINUTE, - tc.pickingDelay , NOW())
- AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE)
- ORDER BY HH,
- mm,
- s.`order` DESC,
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE)
+ ORDER BY HH,
+ mm,
+ s.`order` DESC,
pb.m3 DESC
LIMIT vMaxTicketPrinted;
- -- END IF;
-
-- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores.
- -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado
-
+ -- Se splitan los tickets preparables, para que solo tengan un tipo de empaquetado
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketToSplit;
CREATE TEMPORARY TABLE tmp.ticketToSplit
- SELECT pb.ticketFk
+ SELECT pb.ticketFk, (pb.H + pb.V = 0) isNeutral
FROM tmp.productionBuffer pb
JOIN vn.agencyMode am ON am.id = pb.agencyModeFk
JOIN vn.agency a ON a.id = am.agencyFk
JOIN vn.ticketStateToday tst ON tst.ticket = pb.ticketFk
JOIN vn.state s ON s.id = tst.state
JOIN vn.productionConfig pc
- WHERE ( pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH)
- OR pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
- AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE )
+ WHERE (
+ (pb.H > 0 AND vItemPackingTypeFk = 'H' AND ISNULL(pb.collectionH))
+ OR (pb.V > 0 AND vItemPackingTypeFk = 'V' AND ISNULL(pb.collectionV))
+ OR (pb.N > 0 AND ISNULL(pb.collectionH) AND ISNULL(pb.collectionV))
+ )
+ AND (pb.ubicacion IS NOT NULL
+ OR a.isOwn = FALSE )
AND LENGTH(pb.problem) = 0
AND s.isPreparable
- AND (pc.isPreviousPreparationRequired = FALSE OR pb.previousWithoutParking = FALSE)
+ AND (pc.isPreviousPreparationRequired = FALSE
+ OR pb.previousWithoutParking = FALSE)
ORDER BY pb.HH, pb.mm, s.`order` DESC
LIMIT vMaxTickets;
@@ -55936,104 +56354,113 @@ proc:BEGIN
SELECT MIN(ticketFk) INTO vTicketToSplit
FROM tmp.ticketToSplit;
- CALL vn.ticket_splitItemPackingType(vTicketToSplit);
-
- INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
- SELECT ticketFk, vCollectionFk
- FROM tmp.ticketIPT
- WHERE itemPackingTypeFk = vItemPackingTypeFk;
+ IF (SELECT isNeutral
+ FROM tmp.ticketToSplit
+ WHERE ticketFk = vTicketToSplit) THEN
+
+ INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
+ VALUES(vTicketToSplit, vCollectionFk);
+
+ ELSE
+
+ CALL vn.ticket_splitItemPackingType(vTicketToSplit);
+
+ INSERT INTO vn.ticketCollection(ticketFk, collectionFk)
+ SELECT ticketFk, vCollectionFk
+ FROM tmp.ticketIPT
+ WHERE itemPackingTypeFk = vItemPackingTypeFk;
+
+ DROP TEMPORARY TABLE tmp.ticketIPT;
+
+ END IF;
+
DELETE FROM tmp.ticketToSplit
WHERE ticketFk = vTicketToSplit;
- DROP TEMPORARY TABLE tmp.ticketIPT;
-
END WHILE;
END IF;
- -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- SELECT pb.ticketFk,
- pb.`lines`,
- pb.m3 * 1000 liters,
- 0 as height,
- 0 as shelve,
- 0 as wagon,
- 0 AS shelveLiters,
- pb.productionOrder,
- pb.HH,
- pb.mm
+ -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
+ CREATE TEMPORARY TABLE tmp.ticket
+ SELECT pb.ticketFk,
+ pb.`lines`,
+ pb.m3 * 1000 liters,
+ 0 as height,
+ 0 as shelve,
+ 0 as wagon,
+ 0 AS shelveLiters,
+ pb.productionOrder,
+ pb.HH,
+ pb.mm
FROM tmp.productionBuffer pb
JOIN vn.ticketCollection tc ON tc.ticketFk = pb.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- LIMIT vMaxTickets;
-
+ WHERE tc.collectionFk = vCollectionFk
+ LIMIT vMaxTickets;
+
-- Voumen de las lineas de los pedidos, de acuerdo con el packingShelve establecido por los controladores
- DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters;
- CREATE TEMPORARY TABLE tmp.ticketShelveLiters
- SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters
- FROM tmp.ticket t
- JOIN vn.sale s ON s.ticketFk = t.ticketFk
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.volumeConfig vc
- WHERE i.packingShelve
- GROUP BY t.ticketFk;
-
- UPDATE tmp.ticket t
- JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk
- SET t.shelveLiters = tsl.shelveLiters;
-
- -- Es importante que el primer ticket se coja en todos los casos
- SET vFirstTicketFk = 0;
-
- SELECT ticketFk, HH, mm
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelveLiters;
+ CREATE TEMPORARY TABLE tmp.ticketShelveLiters
+ SELECT t.ticketFk, SUM(s.quantity * vc.shelveVolume / i.packingShelve) shelveLiters
+ FROM tmp.ticket t
+ JOIN vn.sale s ON s.ticketFk = t.ticketFk
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.volumeConfig vc
+ WHERE i.packingShelve
+ GROUP BY t.ticketFk;
+
+ UPDATE tmp.ticket t
+ JOIN tmp.ticketShelveLiters tsl ON tsl.ticketFk = t.ticketFk
+ SET t.shelveLiters = tsl.shelveLiters;
+
+ -- Es importante que el primer ticket se coja en todos los casos
+
+ SET vFirstTicketFk = 0;
+
+ SELECT ticketFk, HH, mm
INTO vFirstTicketFk, vHour, vMinute
FROM tmp.ticket
ORDER BY productionOrder DESC, HH, mm
- LIMIT 1;
-
+ LIMIT 1;
+
-- Hay que excluir aquellos que no tengan la misma hora de preparación
- DELETE
- FROM tmp.ticket
- WHERE HH != vHour
- OR mm != vMinute;
+ DELETE
+ FROM tmp.ticket
+ WHERE HH != vHour
+ OR mm != vMinute;
- -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido
- -- no es monoticket, excluimos a los de más de un carro
- IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000)
- FROM tmp.ticket t
- JOIN vn.volumeConfig vc
+ -- En el caso de pedidos de más volumen de un carro, la colección será monoticket. Pero si el primer pedido
+ -- no es monoticket, excluimos a los de más de un carro
+ IF (SELECT (t.shelveLiters > vc.trolleyM3 * 1000)
+ FROM tmp.ticket t
+ JOIN vn.volumeConfig vc
WHERE t.ticketFk = vFirstTicketFk) THEN
-
- DELETE
- FROM tmp.ticket
- WHERE ticketFk != vFirstTicketFk;
-
+
+ DELETE
+ FROM tmp.ticket
+ WHERE ticketFk != vFirstTicketFk;
+
ELSE
DELETE t.*
- FROM tmp.ticket t
- JOIN vn.volumeConfig vc
- WHERE t.shelveLiters > vc.trolleyM3 * 1000;
+ FROM tmp.ticket t
+ JOIN vn.volumeConfig vc
+ WHERE t.shelveLiters > vc.trolleyM3 * 1000;
- END IF;
-
- -- Elimina los tickets bloqueados que no se van a preparar
+ END IF;
+
+ -- Elimina los tickets bloqueados que no se van a preparar
DELETE tc.*
FROM vn.ticketCollection tc
- LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
+ LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
AND t.ticketFk IS NULL;
- /*
- *
- * Construccion del tren
- *
- */
-
- -- Establece altura máxima por pedido, porque las plantas no se pueden recostar.
+ -- Construccion del tren
+
+ -- Establece altura máxima por pedido, porque las plantas no se pueden recostar.
UPDATE tmp.ticket t
JOIN
( SELECT MAX(i.size) maxHeigth,
@@ -56047,23 +56474,23 @@ proc:BEGIN
SET t.height = IFNULL(sub.maxHeigth,0);
-- Vamos a generar una tabla con todas las posibilidades de asignacion de pedido
- DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry;
- CREATE TEMPORARY TABLE tmp.wagonsVolumetry
+ DROP TEMPORARY TABLE IF EXISTS tmp.wagonsVolumetry;
+ CREATE TEMPORARY TABLE tmp.wagonsVolumetry
SELECT cv.`level` as shelve,
1 as wagon,
- cv.`lines`,
- cv.liters,
- cv.height
+ cv.`lines`,
+ cv.liters,
+ cv.height
FROM vn.collectionVolumetry cv
WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H')
AND cv.trainFk = vTrainFk;
-
+
SET vWagonCounter = 1;
-
- WHILE vWagonCounter < vWagons DO
-
+
+ WHILE vWagonCounter < vWagons DO
+
SET vWagonCounter = vWagonCounter + 1;
-
+
INSERT INTO tmp.wagonsVolumetry(shelve, wagon, `lines`, liters, height)
SELECT cv.`level` as shelve,
vWagonCounter as wagon,
@@ -56073,17 +56500,17 @@ proc:BEGIN
FROM vn.collectionVolumetry cv
WHERE cv.itemPackingTypeFk = IFNULL(vItemPackingTypeFk, 'H')
AND cv.trainFk = vTrainFk;
-
+
END WHILE;
-
+
DROP TEMPORARY TABLE IF EXISTS tmp.ticketShelve;
CREATE TEMPORARY TABLE tmp.ticketShelve
SELECT ticketFk, shelve, wagon, linesDif, LitersDif, heightDif
FROM (
SELECT t.ticketFk,
wv.shelve,
- wv.wagon,
- t.productionOrder,
+ wv.wagon,
+ t.productionOrder,
CAST(wv.`lines` AS SIGNED) - t.`lines` as linesDif,
CAST(wv.liters AS SIGNED) - t.shelveLiters as litersDif,
CAST(wv.height AS SIGNED) - t.height as heightDif
@@ -56095,22 +56522,22 @@ proc:BEGIN
AND heightDif >= 0
ORDER BY productionOrder DESC, linesDif, LitersDif, heightDif ;
- -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo....
- INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif)
+ -- Insertamos una opcion virtual para carro completo. Todo ticket tiene que poder entrar en un carro completo....
+ INSERT INTO tmp.ticketShelve(ticketFk, shelve, wagon, linesDif, LitersDif, heightDif)
SELECT t.ticketFk, 0, wv.wagon, 999, 999,999
FROM tmp.ticket t
- JOIN tmp.wagonsVolumetry wv
- GROUP BY t.ticketFk, wv.wagon;
+ JOIN tmp.wagonsVolumetry wv
+ GROUP BY t.ticketFk, wv.wagon;
- SET vWagonCounter = 0;
-
- WHILE vWagonCounter < vWagons DO
-
+ SET vWagonCounter = 0;
+
+ WHILE vWagonCounter < vWagons DO
+
SET vWagonCounter = vWagonCounter + 1;
-
+
-- Asignamos la primera balda util al primer pedido
- IF vWagonCounter = 1 THEN
-
+ IF vWagonCounter = 1 THEN
+
SELECT shelve INTO vShelve
FROM tmp.ticketShelve
WHERE ticketFk = vFirstTicketFk
@@ -56119,15 +56546,15 @@ proc:BEGIN
LIMIT 1;
ELSE
-
- SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk
+
+ SELECT shelve, ticketFk INTO vShelve, vFirstTicketFk
FROM tmp.ticketShelve
WHERE wagon = vWagonCounter
ORDER BY heightDif, litersDif, linesDif
LIMIT 1;
-
+
END IF;
-
+
IF vShelve > 0 THEN
UPDATE tmp.ticket
@@ -56157,94 +56584,94 @@ proc:BEGIN
OR (shelve = vShelve AND wagon = vWagonCounter);
END WHILE;
-
- ELSE
+
+ ELSE
UPDATE tmp.ticket
SET shelve = 1, wagon = vWagonCounter
WHERE ticketFk = vFirstTicketFk;
-
+
DELETE FROM tmp.ticketShelve
WHERE ticketFk = vFirstTicketFk
AND wagon != vWagonCounter;
END IF;
-
+
END WHILE;
-- Eliminamos los que se han quedado sin balda
DELETE FROM tmp.ticket WHERE shelve = 0;
- -- Elimina los tickets bloqueados que no se van a preparar
+ -- Elimina los tickets bloqueados que no se van a preparar
DELETE tc.*
FROM vn.ticketCollection tc
- LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
+ LEFT JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
AND t.ticketFk IS NULL;
-
+
-- Elimina los tickets que ya estan en otra coleccion
DELETE tc.*
FROM vn.ticketCollection tc
JOIN vn.ticketCollection tc2 ON tc2.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND tc2.collectionFk != vCollectionFk;
+ WHERE tc.collectionFk = vCollectionFk
+ AND tc2.collectionFk != vCollectionFk;
- -- Actualiza el estado de la colección
- UPDATE vn.collection c
+ -- Actualiza el estado de la colección
+ UPDATE vn.collection c
JOIN vn.state st ON st.code = 'ON_PREPARATION'
- SET c.stateFk = st.id
- WHERE c.id = vCollectionFk;
-
+ SET c.stateFk = st.id
+ WHERE c.id = vCollectionFk;
+
-- Asigna las bandejas
- UPDATE vn.ticketCollection tc
+ UPDATE vn.ticketCollection tc
JOIN tmp.ticket t ON t.ticketFk = tc.ticketFk
- SET tc.level = t.shelve,
- tc.wagon = t.wagon,
- tc.itemCount = t.`lines`,
- tc.liters = t.shelveLiters;
+ SET tc.level = t.shelve,
+ tc.wagon = t.wagon,
+ tc.itemCount = t.`lines`,
+ tc.liters = t.shelveLiters;
-- Actualiza el estado de los tickets
INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador)
SELECT vStateFk, ticketFk, account.myUser_getId()
FROM vn.ticketCollection tc
- WHERE tc.collectionFk = vCollectionFk;
+ WHERE tc.collectionFk = vCollectionFk;
- -- Aviso para la preparacion previa
+ -- Aviso para la preparacion previa
INSERT INTO vn.ticketDown(ticketFk, collectionFk)
SELECT tc.ticketFk, tc.collectionFk
- FROM vn.ticketCollection tc
- WHERE tc.collectionFk = vCollectionFk;
-
- IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN
-
- CALL vn.salesMerge_byCollection(vCollectionFk);
-
- UPDATE vn.collection c
- JOIN (SELECT count(*) saleTotalCount ,
- sum(s.isPicked != 0) salePickedCount
- FROM vn.ticketCollection tc
- JOIN vn.sale s ON s.ticketFk = tc.ticketFk
- WHERE tc.collectionFk = vCollectionFk
- AND s.quantity > 0
- ) sub
- SET c.saleTotalCount = sub.saleTotalCount,
- c.salePickedCount = sub.salePickedCount
- WHERE c.id = vCollectionFk;
-
- SELECT vCollectionFk;
-
- ELSE
-
- DELETE FROM vn.collection WHERE id = vCollectionFk;
- -- SELECT NULL;
-
- END IF;
-
- DROP TEMPORARY TABLE tmp.ticketToSplit;
- DROP TEMPORARY TABLE tmp.ticketShelveLiters;
- DROP TEMPORARY TABLE tmp.ticket;
- DROP TEMPORARY TABLE tmp.wagonsVolumetry;
- DROP TEMPORARY TABLE tmp.ticketShelve;
+ FROM vn.ticketCollection tc
+ WHERE tc.collectionFk = vCollectionFk;
+
+ IF (SELECT count(*) FROM vn.ticketCollection WHERE collectionFk = vCollectionFk) THEN
+
+ CALL vn.salesMerge_byCollection(vCollectionFk);
+
+ UPDATE vn.collection c
+ JOIN (SELECT count(*) saleTotalCount ,
+ sum(s.isPicked != 0) salePickedCount
+ FROM vn.ticketCollection tc
+ JOIN vn.sale s ON s.ticketFk = tc.ticketFk
+ WHERE tc.collectionFk = vCollectionFk
+ AND s.quantity > 0
+ ) sub
+ SET c.saleTotalCount = sub.saleTotalCount,
+ c.salePickedCount = sub.salePickedCount
+ WHERE c.id = vCollectionFk;
+
+ SELECT vCollectionFk;
+
+ ELSE
+
+ DELETE FROM vn.collection WHERE id = vCollectionFk;
+
+ END IF;
+
+ DROP TEMPORARY TABLE
+ tmp.ticketToSplit,
+ tmp.ticketShelveLiters,
+ tmp.ticket,
+ tmp.wagonsVolumetry,
+ tmp.ticketShelve;
END ;;
DELIMITER ;
@@ -59304,6 +59731,133 @@ 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 `entry_splitByShelving` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT)
+BEGIN
+ /**
+ * Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr�cula
+ *
+ * @param vShelvingFk Identificador de vn.shelving
+ * @param vFromEntryFk Entrada origen
+ * @param vToEntryFk Entrada destino
+ */
+
+ DECLARE vItemFk INT;
+ DECLARE vStickers INT;
+ DECLARE vBuyFk INT;
+ DECLARE vHasSameStickers BOOL;
+ DECLARE vDone BOOLEAN DEFAULT FALSE;
+ DECLARE cur CURSOR FOR
+ SELECT itemFk, FLOOR(quantity / packing) AS stickers
+ FROM vn.itemShelving WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci ;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ OPEN cur;
+
+ read_loop: LOOP
+
+ FETCH cur INTO vItemFk, vStickers;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+
+ SELECT b.id, (stickers = vStickers) INTO vBuyFk, vHasSameStickers
+ FROM vn.buy
+ WHERE entryFk = vFromEntryFk
+ AND itemFk = vItemFk
+ AND stickers >= vStickers
+ LIMIT 1;
+
+ IF vHasSameStickers THEN
+
+ UPDATE vn.buy SET entryFk = vToEntryFk WHERE id = vBuyFk;
+
+ ELSE
+
+ UPDATE vn.buy SET stickers = stickers - vStickers WHERE id = vBuyFk;
+
+ INSERT INTO vn.buy(entryFk,
+ itemFk,
+ quantity,
+ buyingValue,
+ freightValue,
+ isIgnored,
+ stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
+ producer,
+ printedStickers,
+ workerFk,
+ isChecked,
+ isPickedOff,
+ ektFk,
+ weight,
+ deliveryFk,
+ itemOriginalFk)
+ SELECT
+ vToEntryFk,
+ itemFk,
+ vStickers * packing,
+ buyingValue,
+ freightValue,
+ isIgnored,
+ vStickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ containerFk,
+ comissionValue,
+ packageValue,
+ location,
+ packageFk,
+ price1,
+ price2,
+ price3,
+ minPrice,
+ producer,
+ vStickers,
+ workerFk,
+ isChecked,
+ isPickedOff,
+ ektFk,
+ weight,
+ deliveryFk,
+ itemOriginalFk
+ FROM vn.buy
+ WHERE id = vBuyFk;
+
+ END IF;
+
+ END LOOP;
+
+ CLOSE cur;
+
+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 `entry_splitMisfit` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -72654,11 +73208,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`(vWarehouseFk INT, vScopeDays INT)
proc: BEGIN
@@ -72738,6 +73292,7 @@ proc: BEGIN
, 0 AS N
, st.isOk
, ag.isOwn
+ , rm.bufferFk
FROM tmp.productionTicket tt
JOIN vn.ticket t on tt.ticketFk = t.id
LEFT JOIN vn.ticketStateToday tst ON tst.ticket = t.id
@@ -72763,12 +73318,14 @@ proc: BEGIN
ALTER TABLE tmp.productionBuffer
CHANGE COLUMN `problem` `problem` VARCHAR(255),
ADD COLUMN `collectionH` INT,
- ADD COLUMN `collectionV` INT;
+ ADD COLUMN `collectionV` INT,
+ ADD COLUMN `collectionN` INT;
UPDATE tmp.productionBuffer pb
JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk
SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage,''),
IFNULL(tp.itemDelay,''),
+ IFNULL(tp.itemLost,''),
IF(tp.isFreezed,' CONGELADO',''),
IF(tp.hasHighRisk,' RIESGO',''),
IF(tp.hasTicketRequest, ' COD 100',''),
@@ -72823,20 +73380,13 @@ proc: BEGIN
pb.N = sub2.N;
-- Colecciones segun tipo de encajado
+
UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionH = c.id
- WHERE (c.itemPackingTypeFk = 'H' OR ISNULL(c.itemPackingTypeFk))
- AND pb.H;
-
- UPDATE tmp.productionBuffer pb
- JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
- JOIN vn.collection c ON c.id = tc.collectionFk
- SET pb.collectionV = c.id
- WHERE (c.itemPackingTypeFk = 'V' OR ISNULL(c.itemPackingTypeFk))
- AND pb.V;
-
+ JOIN vn.ticketCollection tc ON pb.ticketFk = tc.ticketFk
+ SET pb.collectionH = IF(pb.H,tc.collectionFk,NULL),
+ pb.collectionV = IF(pb.V,tc.collectionFk,NULL),
+ pb.collectionN = IF(pb.N,tc.collectionFk,NULL);
+
-- Previa pendiente
ALTER TABLE tmp.productionBuffer
ADD previousWithoutParking BOOL DEFAULT FALSE;
@@ -72914,6 +73464,7 @@ proc: BEGIN
WHERE t.shipped between TIMESTAMPADD(WEEK,-1,CURDATE()) AND util.dayend(TIMESTAMPADD(DAY,-1,CURDATE()))
AND wp.warehouse_id = vWarehouseFk;
*/
+
DROP TEMPORARY TABLE tmp.productionTicket;
DROP TEMPORARY TABLE tmp.ticket;
DROP TEMPORARY TABLE tmp.risk;
@@ -76141,221 +76692,263 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_getProblems`(IN vIsTodayRelative tinyint(1))
-BEGIN
-/**
- * Calcula los problemas de cada venta
- * para un conjunto de tickets.
- *
- * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
- * @return tmp.sale_problems
- */
- DECLARE vWarehouse INT;
- DECLARE vDate DATE;
- DECLARE vAvailableCache INT;
- DECLARE vDone INT DEFAULT 0;
- DECLARE vComponentCount INT;
-
- DECLARE vCursor CURSOR FOR
- SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped))
- FROM tmp.sale_getProblems tt
- WHERE DATE(tt.shipped) BETWEEN CURDATE()
- AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE());
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems;
- CREATE TEMPORARY TABLE tmp.sale_problems (
- ticketFk INT(11),
- saleFk INT(11),
- isFreezed INTEGER(1) DEFAULT 0,
- risk DECIMAL(10,2) DEFAULT 0,
- hasHighRisk TINYINT(1) DEFAULT 0,
- hasTicketRequest INTEGER(1) DEFAULT 0,
- isAvailable INTEGER(1) DEFAULT 1,
- itemShortage VARCHAR(250),
- isTaxDataChecked INTEGER(1) DEFAULT 1,
- itemDelay VARCHAR(250),
- hasComponentLack INTEGER(1),
- isTooLittle BOOL DEFAULT FALSE,
- PRIMARY KEY (ticketFk, saleFk)
- ) ENGINE = MEMORY;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
- CREATE TEMPORARY TABLE tmp.ticket_list
- (PRIMARY KEY (ticketFk))
- ENGINE = MEMORY
- SELECT tp.ticketFk, c.id clientFk
- FROM tmp.sale_getProblems tp
- JOIN vn.client c ON c.id = tp.clientFk;
-
- SELECT COUNT(*) INTO vComponentCount
- FROM vn.component c
- WHERE c.isRequired;
-
- INSERT INTO tmp.sale_problems(ticketFk, isTooLittle)
- SELECT sub.ticketFk, TRUE
- FROM (SELECT tl.ticketFk, SUM(sv.litros) litros, t.totalWithoutVat
- FROM tmp.ticket_list tl
- JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE()
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE()))
- AND dm.code IN('AGENCY','DELIVERY','PICKUP')
- GROUP BY tl.ticketFk) sub
- JOIN vn.volumeConfig vc
- WHERE sub.litros < vc.minTicketVolume
- AND sub.totalWithoutVat < vc.minTicketValue;
-
- INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
- SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id
- FROM tmp.ticket_list tl
- JOIN vn.sale s ON s.ticketFk = tl.ticketFk
- LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
- LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode am ON am.id = t.agencyModeFk
- JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
- WHERE dm.code IN('AGENCY','DELIVERY','PICKUP')
- GROUP BY tl.ticketFk, s.id;
-
- INSERT INTO tmp.sale_problems(ticketFk, isFreezed)
- SELECT DISTINCT tl.ticketFk, TRUE
- FROM tmp.ticket_list tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isFreezed
- ON DUPLICATE KEY UPDATE
- isFreezed = c.isFreezed;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
- CREATE TEMPORARY TABLE tmp.clientGetDebt
- (PRIMARY KEY (clientFk))
- ENGINE = MEMORY
- SELECT DISTINCT clientFk
- FROM tmp.ticket_list;
-
- CALL clientGetDebt(CURDATE());
-
- INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk)
- SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10)
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.agencyMode a ON t.agencyModeFk = a.id
- JOIN tmp.risk r ON r.clientFk = t.clientFk
- JOIN vn.client c ON c.id = t.clientFk
- JOIN vn.clientConfig cc
- WHERE r.risk > c.credit + 10
- AND a.isRiskFree = FALSE
- ON DUPLICATE KEY UPDATE
- risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10);
-
- INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest)
- SELECT DISTINCT tl.ticketFk, TRUE
- FROM tmp.ticket_list tl
- JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
- WHERE tr.isOK IS NULL
- ON DUPLICATE KEY UPDATE
- hasTicketRequest = TRUE;
-
- OPEN vCursor;
-
- WHILE NOT vDone
- DO
- FETCH vCursor INTO vWarehouse, vDate;
-
- CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate);
-
- INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk)
- SELECT tl.ticketFk, FALSE, s.id
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN cache.available av ON av.item_id = i.id
- AND av.calc_id = vAvailableCache
- WHERE date(t.shipped) = vDate
- AND it.categoryFk != 6
- AND IFNULL(av.available, 0) < 0
- AND s.isPicked = FALSE
- AND NOT i.generic
- AND vWarehouse = t.warehouseFk
- GROUP BY tl.ticketFk
- ON DUPLICATE KEY UPDATE
- isAvailable = FALSE, saleFk = VALUES(saleFk);
-
- INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk)
- SELECT ticketFk, problem, saleFk
- FROM (
- SELECT tl.ticketFk, CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem, s.id AS saleFk
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- WHERE IFNULL(av.available, 0) <= 0
- AND s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk) sub
- ON DUPLICATE KEY UPDATE
- itemShortage = sub.problem, saleFk = sub.saleFk;
-
- INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk)
- SELECT ticketFk, problem, saleFk
- FROM (
- SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
- FROM tmp.ticket_list tl
- JOIN vn.ticket t ON t.id = tl.ticketFk
- JOIN vn.sale s ON s.ticketFk = t.id
- JOIN vn.item i ON i.id = s.itemFk
- JOIN vn.itemType it on it.id = i.typeFk
- LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
- LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
- WHERE IFNULL(av.available, 0) >= s.quantity
- AND s.quantity > IFNULL(issw.visible, 0)
- AND s.quantity > 0
- AND s.isPicked = FALSE
- AND s.reserved = FALSE
- AND it.categoryFk != 6
- AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
- AND NOT i.generic
- AND CURDATE() = vDate
- AND t.warehouseFk = vWarehouse
- GROUP BY tl.ticketFk) sub
- ON DUPLICATE KEY UPDATE
- itemDelay = sub.problem, saleFk = sub.saleFk;
- END WHILE;
-
- CLOSE vCursor;
-
- INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked)
- SELECT DISTINCT tl.ticketFk, FALSE
- FROM tmp.ticket_list tl
- JOIN vn.client c ON c.id = tl.clientFk
- WHERE c.isTaxDataChecked = FALSE
- ON DUPLICATE KEY UPDATE
- isTaxDataChecked = FALSE;
-
- DROP TEMPORARY TABLE
- tmp.clientGetDebt,
- tmp.ticket_list;
+BEGIN
+ /**
+ * Calcula los problemas de cada venta
+ * para un conjunto de tickets.
+ *
+ * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy
+ * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
+ * @return tmp.sale_problems
+ */
+
+ DECLARE vWarehouseFk INT;
+ DECLARE vDate DATE;
+ DECLARE vAvailableCache INT;
+ DECLARE vVisibleCache INT;
+ DECLARE vDone INT DEFAULT 0;
+ DECLARE vComponentCount INT;
+
+ DECLARE vCursor CURSOR FOR
+ SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, CURDATE(), date(tt.shipped))
+ FROM tmp.sale_getProblems tt
+ WHERE DATE(tt.shipped) BETWEEN CURDATE()
+ AND TIMESTAMPADD(DAY, IF(vIsTodayRelative, 9.9, 1.9), CURDATE());
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.sale_problems;
+ CREATE TEMPORARY TABLE tmp.sale_problems (
+ ticketFk INT(11),
+ saleFk INT(11),
+ isFreezed INTEGER(1) DEFAULT 0,
+ risk DECIMAL(10,2) DEFAULT 0,
+ hasHighRisk TINYINT(1) DEFAULT 0,
+ hasTicketRequest INTEGER(1) DEFAULT 0,
+ isAvailable INTEGER(1) DEFAULT 1,
+ itemShortage VARCHAR(250),
+ isTaxDataChecked INTEGER(1) DEFAULT 1,
+ itemDelay VARCHAR(250),
+ itemLost VARCHAR(250),
+ hasComponentLack INTEGER(1),
+ isTooLittle BOOL DEFAULT FALSE,
+ PRIMARY KEY (ticketFk, saleFk)
+ ) ENGINE = MEMORY;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
+ CREATE TEMPORARY TABLE tmp.ticket_list
+ (PRIMARY KEY (ticketFk))
+ ENGINE = MEMORY
+ SELECT tp.ticketFk, tp.clientFk
+ FROM tmp.sale_getProblems tp;
+
+ SELECT COUNT(*) INTO vComponentCount
+ FROM vn.component c
+ WHERE c.isRequired;
+
+ -- Too Little
+ INSERT INTO tmp.sale_problems(ticketFk, isTooLittle)
+ SELECT sub.ticketFk, TRUE
+ FROM (SELECT tl.ticketFk, SUM(sv.litros) litros, t.totalWithoutVat
+ FROM tmp.ticket_list tl
+ JOIN vn.saleVolume sv ON sv.ticketFk = tl.ticketFk
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = CURDATE()
+ JOIN vn.agencyMode am ON am.id = t.agencyModeFk
+ JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
+ WHERE NOW() < TIMESTAMPADD(MINUTE,MINUTE(zc.`hour`) ,TIMESTAMPADD(HOUR,HOUR(zc.`hour`),CURDATE()))
+ AND dm.code IN('AGENCY','DELIVERY','PICKUP')
+ GROUP BY tl.ticketFk) sub
+ JOIN vn.volumeConfig vc
+ WHERE sub.litros < vc.minTicketVolume
+ AND sub.totalWithoutVat < vc.minTicketValue;
+
+ -- Faltan componentes
+ INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk)
+ SELECT tl.ticketFk, (COUNT(DISTINCT s.id) * vComponentCount > COUNT(c.id)), s.id
+ FROM tmp.ticket_list tl
+ JOIN vn.sale s ON s.ticketFk = tl.ticketFk
+ LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
+ LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.agencyMode am ON am.id = t.agencyModeFk
+ JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
+ WHERE dm.code IN('AGENCY','DELIVERY','PICKUP')
+ GROUP BY tl.ticketFk, s.id;
+
+ -- Cliente congelado
+ INSERT INTO tmp.sale_problems(ticketFk, isFreezed)
+ SELECT DISTINCT tl.ticketFk, TRUE
+ FROM tmp.ticket_list tl
+ JOIN vn.client c ON c.id = tl.clientFk
+ WHERE c.isFreezed
+ ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed;
+
+ -- Cr�dito excedido
+ DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
+ CREATE TEMPORARY TABLE tmp.clientGetDebt
+ (PRIMARY KEY (clientFk))
+ ENGINE = MEMORY
+ SELECT DISTINCT clientFk
+ FROM tmp.ticket_list;
+
+ CALL clientGetDebt(CURDATE());
+
+ INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk)
+ SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10)
+ FROM tmp.ticket_list tl
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.agencyMode a ON t.agencyModeFk = a.id
+ JOIN tmp.risk r ON r.clientFk = t.clientFk
+ JOIN vn.client c ON c.id = t.clientFk
+ JOIN vn.clientConfig cc
+ WHERE r.risk > c.credit + 10
+ AND a.isRiskFree = FALSE
+ ON DUPLICATE KEY UPDATE
+ risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10);
+
+ -- Antiguo COD 100, son peticiones de compra sin terminar
+ INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest)
+ SELECT DISTINCT tl.ticketFk, TRUE
+ FROM tmp.ticket_list tl
+ JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
+ WHERE tr.isOK IS NULL
+ ON DUPLICATE KEY UPDATE hasTicketRequest = TRUE;
+
+ -- Disponible, Faltas, Inventario y Retrasos
+ OPEN vCursor;
+
+ WHILE NOT vDone DO
+
+ FETCH vCursor INTO vWarehouseFk, vDate;
+
+ -- Disponible: no va a haber suficiente producto para preparar todos los pedidos
+ CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouseFk, vDate);
+
+ INSERT INTO tmp.sale_problems(ticketFk, isAvailable, saleFk)
+ SELECT tl.ticketFk, FALSE, s.id
+ FROM tmp.ticket_list tl
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
+ WHERE date(t.shipped) = vDate
+ AND ic.merchandise = TRUE
+ AND IFNULL(av.available, 0) < 0
+ AND s.isPicked = FALSE
+ AND NOT i.generic
+ AND vWarehouseFk = t.warehouseFk
+ GROUP BY tl.ticketFk
+ ON DUPLICATE KEY UPDATE isAvailable = FALSE, saleFk = VALUES(saleFk);
+
+ -- Faltas: visible, disponible y ubicado son menores que la cantidad vendida
+ CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk);
+
+ INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk)
+ SELECT ticketFk, problem, saleFk
+ FROM (
+ SELECT tl.ticketFk,
+ CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')) problem,
+ s.id AS saleFk
+ FROM tmp.ticket_list tl
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache
+ LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) < s.quantity
+ AND IFNULL(av.available ,0) < s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
+ AND NOT i.generic
+ AND CURDATE() = vDate
+ AND t.warehouseFk = vWarehouseFk
+ GROUP BY tl.ticketFk) sub
+ ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk;
+
+ -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida
+ INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk)
+ SELECT ticketFk, problem, saleFk
+ FROM (
+ SELECT tl.ticketFk, GROUP_CONCAT('I: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
+ FROM tmp.ticket_list tl
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) >= s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.quantity > 0
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
+ AND NOT i.generic
+ AND CURDATE() = vDate
+ AND t.warehouseFk = vWarehouseFk
+ GROUP BY tl.ticketFk) sub
+ ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
+
+ -- Retraso: Disponible suficiente, pero no visible ni ubicado
+ INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk)
+ SELECT ticketFk, problem, saleFk
+ FROM (
+ SELECT tl.ticketFk, GROUP_CONCAT('R: ',i.id, ' ', i.longName, ' ') problem, s.id AS saleFk
+ FROM tmp.ticket_list tl
+ JOIN vn.ticket t ON t.id = tl.ticketFk
+ JOIN vn.sale s ON s.ticketFk = t.id
+ JOIN vn.item i ON i.id = s.itemFk
+ JOIN vn.itemType it on it.id = i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache
+ LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
+ LEFT JOIN vn.itemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk
+ WHERE IFNULL(v.visible,0) < s.quantity
+ AND IFNULL(av.available ,0) >= s.quantity
+ AND IFNULL(issw.visible, 0) < s.quantity
+ AND s.quantity > 0
+ AND s.isPicked = FALSE
+ AND s.reserved = FALSE
+ AND ic.merchandise = TRUE
+ AND IF(vIsTodayRelative, TRUE, date(t.shipped) = vDate)
+ AND NOT i.generic
+ AND CURDATE() = vDate
+ AND t.warehouseFk = vWarehouseFk
+ GROUP BY tl.ticketFk) sub
+ ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk;
+ END WHILE;
+
+ CLOSE vCursor;
+
+ INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked)
+ SELECT DISTINCT tl.ticketFk, FALSE
+ FROM tmp.ticket_list tl
+ JOIN vn.client c ON c.id = tl.clientFk
+ WHERE c.isTaxDataChecked = FALSE
+ ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE;
+
+ DROP TEMPORARY TABLE
+ tmp.clientGetDebt,
+ tmp.ticket_list;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -76980,11 +77573,11 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sectorCollection_get`(vSectorFk INT)
BEGIN
@@ -77005,7 +77598,8 @@ BEGIN
WHERE sc.userFk = account.myUser_getId()
AND (ISNULL(scsg.sectorCollectionFk)
OR
- (NOT st.isChecked AND sl.quantity > 0));
+ (NOT st.isChecked AND sl.quantity > 0))
+ AND sc.created > CURDATE();
END ;;
DELIMITER ;
@@ -83566,65 +84160,70 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8 */ ;
-/*!50003 SET character_set_results = utf8 */ ;
-/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET character_set_client = utf8mb4 */ ;
+/*!50003 SET character_set_results = utf8mb4 */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_doRecalc`()
-proc: BEGIN
-/**
- * Recalculates modified ticket.
- */
-
- DECLARE vDone BOOL;
- DECLARE vTicketFk INT;
-
- DECLARE cCur CURSOR FOR
- SELECT ticketFk FROM ticketRecalc;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
- BEGIN
- DO RELEASE_LOCK('vn.ticket_doRecalc');
+proc: BEGIN
+/**
+ * Recalculates modified ticket.
+ */
+
+ DECLARE vDone BOOL;
+ DECLARE vTicketFk INT;
+
+ DECLARE cCur CURSOR FOR
+ SELECT ticketFk FROM ticketRecalc;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+ BEGIN
+ DO RELEASE_LOCK('vn.ticket_doRecalc');
ROLLBACK;
- GET DIAGNOSTICS CONDITION 2 @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
- CALL `vn`.`mail_insert`('robert@verdnatura.es',
- NULL,
- 'Problema al recalcular el total de ticket',
- CONCAT('Se ha detectato un problema en ticket_doRecalc al calcular el total del ticket : ',
- vTicketFk,' el error es el: ',
- CONCAT('ERROR ', IFNULL(@errno, 0), ': ', ifnull(@text, '')))
- );
- RESIGNAL;
- END;
-
- IF !GET_LOCK('vn.ticket_doRecalc', 0) THEN
- LEAVE proc;
- END IF;
-
- OPEN cCur;
-
- myLoop: LOOP
- SET vDone = FALSE;
- FETCH cCur INTO vTicketFk;
-
- IF vDone THEN
- LEAVE myLoop;
- END IF;
-
- START TRANSACTION;
- CALL ticket_recalc(vTicketFk);
-
+ RESIGNAL;
+ END;
+
+ IF !GET_LOCK('vn.ticket_doRecalc', 0) THEN
+ LEAVE proc;
+ END IF;
+
+ OPEN cCur;
+
+ myLoop: LOOP
+ SET vDone = FALSE;
+ FETCH cCur INTO vTicketFk;
+
+ IF vDone THEN
+ LEAVE myLoop;
+ END IF;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
+ CREATE TEMPORARY TABLE tmp.ticket
+ ENGINE = MEMORY
+ SELECT vTicketFk ticketFk;
+
+ CALL ticketGetTotal;
+
+ START TRANSACTION;
+ UPDATE ticket t
+ JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
+ SET t.totalWithVat = tt.total,
+ t.totalWithoutVat = tt.totalWithoutVat;
DELETE FROM ticketRecalc WHERE ticketFk = vTicketFk;
- COMMIT;
- END LOOP;
-
- CLOSE cCur;
- DO RELEASE_LOCK('vn.ticket_doRecalc');
+ COMMIT;
+
+ DROP TEMPORARY TABLE
+ tmp.ticket,
+ tmp.ticketTotal;
+ END LOOP;
+
+ CLOSE cCur;
+ DO RELEASE_LOCK('vn.ticket_doRecalc');
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -83922,42 +84521,46 @@ BEGIN
* @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular
* @return tmp.ticket_problems
*/
- CALL sale_getProblems(vIsTodayRelative);
+ CALL sale_getProblems(vIsTodayRelative);
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems;
- CREATE TEMPORARY TABLE tmp.ticket_problems
- (PRIMARY KEY (ticketFk))
- ENGINE = MEMORY
- SELECT
- ticketFk,
- MAX(p.isFreezed) AS isFreezed,
- MAX(p.risk) AS risk,
- MAX(p.hasHighRisk) AS hasHighRisk,
- MAX(p.hasTicketRequest) AS hasTicketRequest,
- MIN(p.isAvailable) AS isAvailable,
- MAX(p.itemShortage) AS itemShortage,
- MIN(p.isTaxDataChecked) AS isTaxDataChecked,
- MAX(p.hasComponentLack) AS hasComponentLack,
- MAX(p.isTooLittle) AS isTooLittle,
- max(p.itemDelay) AS itemDelay,
- 0 AS totalProblems
- FROM tmp.sale_problems p
- GROUP BY ticketFk;
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket_problems;
+ CREATE TEMPORARY TABLE tmp.ticket_problems
+ (PRIMARY KEY (ticketFk))
+ ENGINE = MEMORY
+ SELECT
+ ticketFk,
+ MAX(p.isFreezed) AS isFreezed,
+ MAX(p.risk) AS risk,
+ MAX(p.hasHighRisk) AS hasHighRisk,
+ MAX(p.hasTicketRequest) AS hasTicketRequest,
+ MIN(p.isAvailable) AS isAvailable,
+ MAX(p.itemShortage) AS itemShortage,
+ MIN(p.isTaxDataChecked) AS isTaxDataChecked,
+ MAX(p.hasComponentLack) AS hasComponentLack,
+ MAX(p.isTooLittle) AS isTooLittle,
+ MAX(p.itemDelay) AS itemDelay,
+ MAX(p.itemLost) AS itemLost,
+ 0 AS totalProblems
+ FROM tmp.sale_problems p
+ GROUP BY ticketFk;
- UPDATE tmp.ticket_problems tp
- SET tp.totalProblems = (
- (tp.isFreezed) +
- IF(tp.risk, TRUE, FALSE) +
- (tp.hasTicketRequest) +
- (tp.isAvailable = 0) +
- (tp.isTaxDataChecked = 0) +
- (tp.hasComponentLack) +
- (tp.itemDelay) +
- (tp.isTooLittle)
- );
+ UPDATE tmp.ticket_problems tp
+ SET tp.totalProblems =
+ (
+ (tp.isFreezed) +
+ IF(tp.risk, TRUE, FALSE) +
+ (tp.hasTicketRequest) +
+ (tp.isAvailable = 0) +
+ (tp.isTaxDataChecked = 0) +
+ (tp.hasComponentLack) +
+ (tp.itemDelay) +
+ (tp.isTooLittle) +
+ (tp.itemLost) +
+ (tp.itemShortage)
+ );
- DROP TEMPORARY TABLE
- tmp.sale_problems;
+ DROP TEMPORARY TABLE
+ tmp.sale_problems;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -86697,44 +87300,44 @@ BEGIN
/**
* Clona los travels plantilla para las semanas pasadas por parámetros
*
- * @param vSinceWeek Numero de semanas en el futuro para empezar a clonar
+ * @param vSinceWeek Número de semanas en el futuro para empezar a clonar
* @param vToWeek Número de semenas en el futuro hasta donde clonar
*/
-
+
DECLARE vCounter INT;
DECLARE vCurrentTravelFk INT;
DECLARE vShipped DATE;
DECLARE vLanded DATE;
- DECLARE vWarehouseInFk INT;
- DECLARE vWarehouseOutFk INT;
+ DECLARE vWarehouseInFk INT;
+ DECLARE vWarehouseOutFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vRef VARCHAR(255);
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vRsTravel CURSOR FOR
- SELECT travelFk,
- @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
- @a := TIMESTAMPADD(DAY,duration,@a),
- warehouseOutFk,
- warehouseInFk,
- `ref`,
- agencyModeFk
- FROM travel_cloneWeekly
- WHERE travelFk;
-
+ SELECT travelFk,
+ @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
+ @a := TIMESTAMPADD(DAY,duration,@a),
+ warehouseOutFk,
+ warehouseInFk,
+ `ref`,
+ agencyModeFk
+ FROM travelClonedWeekly
+ WHERE travelFk;
+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SET vCounter = vSinceWeek;
vWeekLoop :LOOP
- INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk, kg)
- SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
- @a := TIMESTAMPADD(DAY, duration, @a),
- warehouseOutFk,
- warehouseInFk,
- agencyModeFk,
- ref,
- cargoSupplierFk,
- kg
- FROM travel_cloneWeekly
+ INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk, kg)
+ SELECT @a := TIMESTAMPADD(DAY, vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
+ @a := TIMESTAMPADD(DAY, duration, @a),
+ warehouseOutFk,
+ warehouseInFk,
+ agencyModeFk,
+ ref,
+ supplierFk,
+ kg
+ FROM travelClonedWeekly
WHERE travelFk IS NULL;
OPEN vRsTravel;
FETCH vRsTravel INTO vCurrentTravelFk, vShipped, vLanded, vWarehouseOutFk, vWarehouseInFk, vRef, vAgencyModeFk;
@@ -86744,12 +87347,12 @@ BEGIN
FETCH vRsTravel INTO vCurrentTravelFk, vShipped, vLanded, vWarehouseOutFk, vWarehouseInFk, vRef, vAgencyModeFk;
END WHILE;
CLOSE vRsTravel;
-
+
IF vCounter = vToWeek THEN
LEAVE vWeekLoop;
END IF;
- SET vCounter = vCounter + 1;
-
+ SET vCounter = vCounter + 1;
+
END LOOP vWeekLoop;
END ;;
@@ -86758,43 +87361,6 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-/*!50003 DROP PROCEDURE IF EXISTS `travel_weeklyClone__` */;
-/*!50003 SET @saved_cs_client = @@character_set_client */ ;
-/*!50003 SET @saved_cs_results = @@character_set_results */ ;
-/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
-/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
-DELIMITER ;;
-CREATE DEFINER=`root`@`localhost` PROCEDURE `travel_weeklyClone__`(vSinceWeek INT, vToWeek INT)
-BEGIN
- DECLARE vCounter INT;
-
- SET vCounter = vSinceWeek;
- vWeekLoop :LOOP
- INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk, kg)
- SELECT @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()),
- @a := TIMESTAMPADD(DAY,duration,@a),
- warehouseOutFk,
- warehouseInFk,
- agencyModeFk,
- ref,
- cargoSupplierFk,
- kg
- FROM travel_cloneWeekly;
- IF vCounter = vToWeek THEN
- LEAVE vWeekLoop;
- END IF;
- SET vCounter = vCounter + 1;
- END LOOP;
-END ;;
-DELIMITER ;
-/*!50003 SET sql_mode = @saved_sql_mode */ ;
-/*!50003 SET character_set_client = @saved_cs_client */ ;
-/*!50003 SET character_set_results = @saved_cs_results */ ;
-/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `typeTagMake` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
@@ -87925,9 +88491,9 @@ DELIMITER ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
+/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
-/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `workerJourney_replace`(vDatedFrom DATE, vDatedTo DATE, vWorkerFk INT)
BEGIN
@@ -87937,7 +88503,7 @@ BEGIN
* @param vDatedTo workerTimeControl
* @param vWorkerFk, en caso de pasar 0 ó NULL se aplica a todos
*/
-
+
DECLARE vDatedTimeTo DATETIME;
DECLARE vMaxTimePerDay INT;
DECLARE vMinHoursToBreak DECIMAL(10,2);
@@ -87946,6 +88512,11 @@ BEGIN
DECLARE vWeeksByYear INT DEFAULT 52;
DECLARE vMonthsByYear INT DEFAULT 12;
DECLARE vDaysByWeek INT DEFAULT 5;
+ DECLARE vDatedFromYesterday DATETIME;
+ DECLARE vDatedToTomorrow DATETIME;
+
+ SELECT DATE_SUB(vDatedFrom, INTERVAL 1 DAY), DATE_ADD(vDatedTo, INTERVAL 1 DAY)
+ INTO vDatedFromYesterday, vDatedToTomorrow;
SET vDatedTimeTo = util.dayEnd(vDatedTo);
@@ -87996,6 +88567,94 @@ BEGIN
SET @vIsOdd := TRUE;
SET @vDated := NULL;
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControl;
+ CREATE TEMPORARY TABLE tmp.workerTimeControl
+ (INDEX (userFk), INDEX (timed))
+ ENGINE = MEMORY
+ SELECT DISTINCT(wtc.id),
+ wtc.userFk,
+ wtc.timed,
+ wtc.direction
+ FROM workerTimeControl wtc
+ JOIN tmp.`user` w ON w.userFk = wtc.userFk
+ LEFT JOIN tmp.timeControlError tce ON tce.id = wtc.id
+ WHERE wtc.timed BETWEEN vDatedFrom AND vDatedToTomorrow
+ AND tce.id IS NULL
+ AND (vWorkerFk IS NULL OR wtc.userFk = vWorkerFk)
+ ORDER BY wtc.userFk, wtc.timed ASC;
+
+ SELECT MAX(id) INTO @vCont
+ FROM tmp.workerTimeControl;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlAux;
+ CREATE TEMPORARY TABLE tmp.workerTimeControlAux (
+ `id` int(11) ,
+ `userFk` int(10) unsigned ,
+ `timed` datetime,
+ `direction` enum('in', 'out','middle')
+ ) ENGINE=MEMORY;
+
+ SET @counter := 0;
+ SET @vIsOdd := FALSE;
+
+ -- Cambio de dia en medio de un descanso
+ INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
+ SELECT @vCont:= @vCont + 1 id, userFk, util.dayEnd(dated) timed, 'middle' direction
+ FROM(SELECT wtc.userFk,
+ DATE(@lastTimed) dated,
+ (@vIsOdd := NOT @vIsOdd) isOdd,
+ IF(@vIsOdd AND wtc.direction = 'middle' AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak,
+ @lastTimed := wtc.timed
+ FROM tmp.workerTimeControl wtc
+ ORDER BY wtc.userFk, wtc.timed
+ )sub
+ WHERE hasBreak;
+
+ SET @counter := 0;
+ SET @vIsOdd := FALSE;
+
+ INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
+ SELECT @vCont:= @vCont + 1, userFk, DATE_ADD(sub.dated, INTERVAL 1 DAY), 'middle'
+ FROM(SELECT wtc.userFk,
+ DATE(@lastTimed) dated,
+ (@vIsOdd := NOT @vIsOdd) isOdd,
+ IF(@vIsOdd AND wtc.direction = 'middle' AND DATE(timed) <> DATE(@lastTimed), TRUE, FALSE) hasBreak,
+ @lastTimed := wtc.timed
+ FROM tmp.workerTimeControl wtc
+ ORDER BY wtc.userFk, wtc.timed
+ )sub
+ WHERE hasBreak;
+
+ -- Cambio de dia
+ INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
+ SELECT @vCont:= @vCont + 1 id, sub.userFk, util.dayEnd(sub.dated) timed, 'out' direction
+ FROM (SELECT MAX(wtc.timed) timed, wtc.userFk, date(wtc.timed) dated
+ FROM workerTimeControl wtc
+ JOIN tmp.`user` w ON w.userFk = wtc.userFk
+ LEFT JOIN tmp.timeControlError tce ON tce.id = wtc.id
+ WHERE wtc.timed BETWEEN vDatedFromYesterday AND vDatedToTomorrow
+ AND tce.id IS NULL
+ GROUP BY wtc.userFk, DATE(wtc.timed)
+ ) sub
+ JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed AND wtc.userFk = sub.userFk
+ WHERE wtc.direction <> 'out';
+
+ INSERT INTO tmp.workerTimeControlAux (id, userFk, timed, direction)
+ SELECT @vCont:= @vCont + 1, sub.userFk, DATE_ADD(sub.dated, INTERVAL 1 DAY), 'in'
+ FROM (SELECT MAX(wtc.timed) timed, wtc.userFk, date(wtc.timed) dated
+ FROM workerTimeControl wtc
+ JOIN tmp.`user` w ON w.userFk = wtc.userFk
+ LEFT JOIN tmp.timeControlError tce ON tce.id = wtc.id
+ WHERE wtc.timed BETWEEN vDatedFromYesterday AND vDatedToTomorrow
+ AND tce.id IS NULL
+ GROUP BY wtc.userFk, DATE(wtc.timed)
+ ) sub
+ JOIN tmp.workerTimeControl wtc ON wtc.timed = sub.timed AND wtc.userFk = sub.userFk
+ WHERE wtc.direction <> 'out';
+
+ INSERT INTO tmp.workerTimeControl (id, userFk, timed, direction)
+ SELECT id, userFk, timed, direction
+ FROM tmp.workerTimeControlAux;
UPDATE workerJourney wj
JOIN (SELECT sub.dated, userFk, SUM(NigthlyHours) NigthlyHours
@@ -88008,17 +88667,14 @@ BEGIN
vn.workerNigthlyHours_calculate(FROM_UNIXTIME(@vLastTimed), wtc.timed),
0) NigthlyHours
FROM (SELECT DISTINCT(wtc.id), wtc.userFk, wtc.timed, wtc.direction
- FROM workerTimeControl wtc
+ FROM tmp.workerTimeControl wtc
LEFT JOIN tmp.timeControlError tce ON tce.id = wtc.id
- WHERE wtc.timed BETWEEN vDatedFrom AND util.dayEnd(DATE_ADD(vDatedTo, INTERVAL 1 DAY))
+ WHERE wtc.timed BETWEEN vDatedFrom AND util.dayEnd(vDatedToTomorrow)
AND tce.id IS NULL
ORDER BY userFk, timed ASC
) wtc
)sub
-
-
- WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
-
+ WHERE sub.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY userFk, sub.dated
)night ON night.userFk = wj.userFk AND night.dated = wj.dated
SET wj.nocturn = night.NigthlyHours
@@ -88112,6 +88768,8 @@ BEGIN
DROP TEMPORARY TABLE tmp.timeControlCalculate;
DROP TEMPORARY TABLE tmp.`user`;
DROP TEMPORARY TABLE tmp.timeControlError;
+ DROP TEMPORARY TABLE tmp.workerTimeControlAux;
+ DROP TEMPORARY TABLE tmp.workerTimeControl;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -94480,7 +95138,7 @@ USE `hedera`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */
+/*!50001 VIEW `myAddress` AS select `t`.`id` AS `id`,`t`.`clientFk` AS `clientFk`,`t`.`street` AS `street`,`t`.`city` AS `city`,`t`.`postalCode` AS `postalCode`,`t`.`provinceFk` AS `provinceFk`,`t`.`nickname` AS `nickname`,`t`.`isDefaultAddress` AS `isDefaultAddress`,`t`.`isActive` AS `isActive`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`agencyModeFk` AS `agencyModeFk` from `vn`.`address` `t` where (`t`.`clientFk` = `account`.`myUser_getId`()) */
/*!50002 WITH CASCADED CHECK OPTION */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
@@ -95205,25 +95863,6 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
---
--- Final view structure for view `accounting`
---
-
-/*!50001 DROP TABLE IF EXISTS `accounting`*/;
-/*!50001 DROP VIEW IF EXISTS `accounting`*/;
-/*!50001 SET @saved_cs_client = @@character_set_client */;
-/*!50001 SET @saved_cs_results = @@character_set_results */;
-/*!50001 SET @saved_col_connection = @@collation_connection */;
-/*!50001 SET character_set_client = utf8mb4 */;
-/*!50001 SET character_set_results = utf8mb4 */;
-/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `accounting` AS select `b`.`id` AS `id`,`b`.`bank` AS `bank`,`b`.`account` AS `account`,`b`.`cash` AS `accountingTypeFk`,`b`.`entityFk` AS `entityFk`,`b`.`isActive` AS `isActive`,`b`.`currencyFk` AS `currencyFk` from `bank` `b` */;
-/*!50001 SET character_set_client = @saved_cs_client */;
-/*!50001 SET character_set_results = @saved_cs_results */;
-/*!50001 SET collation_connection = @saved_col_connection */;
-
--
-- Final view structure for view `agencyProvince__`
--
@@ -95281,6 +95920,25 @@ USE `vn`;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
+--
+-- Final view structure for view `bank`
+--
+
+/*!50001 DROP TABLE IF EXISTS `bank`*/;
+/*!50001 DROP VIEW IF EXISTS `bank`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = utf8mb4 */;
+/*!50001 SET character_set_results = utf8mb4 */;
+/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `bank` AS select `a`.`id` AS `id`,`a`.`bank` AS `bank`,`a`.`account` AS `account`,`a`.`accountingTypeFk` AS `cash`,`a`.`entityFk` AS `entityFk`,`a`.`isActive` AS `isActive`,`a`.`currencyFk` AS `currencyFk`,`a`.`code` AS `code` from `accounting` `a` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+
--
-- Final view structure for view `bankPolicy`
--
@@ -96188,7 +96846,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (curdate() + interval -(1) year)) */;
+/*!50001 VIEW `invoiceCorrectionDataSource` AS select `s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`s`.`price` AS `price`,`s`.`discount` AS `discount`,`t`.`refFk` AS `refFk`,`s`.`id` AS `saleFk`,`t`.`shipped` AS `shipped` from (`sale` `s` join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) where (`t`.`shipped` > (curdate() + interval -(3) year)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -96232,11 +96890,11 @@ USE `vn`;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `invoiceInIntrastat__`
+-- Final view structure for view `invoiceInIntrastat2__`
--
-/*!50001 DROP TABLE IF EXISTS `invoiceInIntrastat__`*/;
-/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat__`*/;
+/*!50001 DROP TABLE IF EXISTS `invoiceInIntrastat2__`*/;
+/*!50001 DROP VIEW IF EXISTS `invoiceInIntrastat2__`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -96245,7 +96903,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_unicode_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `invoiceInIntrastat__` AS select `r`.`recibida_id` AS `invoiceInFk`,`r`.`Codintrastat` AS `intrastatFk`,`r`.`importe` AS `amount` from `vn2008`.`recibida_intrastat` `r` */;
+/*!50001 VIEW `invoiceInIntrastat2__` AS select `id`.`id` AS `id`,`id`.`recibida_id` AS `invoiceInFk`,`id`.`neto` AS `net`,`id`.`intrastat_id` AS `intrastatFk`,`id`.`importe` AS `amount`,`id`.`unidades` AS `stems`,`id`.`Paises_Id` AS `countryFk`,`id`.`odbc_date` AS `dated`,`id`.`valorestadistico` AS `statisticalValue` from `vn2008`.`intrastat_data` `id` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -98032,4 +98690,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2022-03-14 10:24:57
+-- Dump completed on 2022-03-28 9:44:10