diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 109c24544..857df70d3 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -1233,11 +1233,18 @@ INSERT INTO `vn`.`annualAverageInvoiced`(`clientFk`, `invoiced`)
(104, 500),
(105, 5000);
-INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`)
+INSERT INTO `vn`.`supplierActivity`(`code`, `name`)
VALUES
- (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18),
- (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18),
- (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18);
+ ('animals', 'Food and complements for pets'),
+ ('complements', 'Other complements'),
+ ('flowerPlants', 'Wholesale of flowers and plants'),
+ ('vegetablesFruits', 'Fruit and vegetable trade');
+
+INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`,`isFarmer`,`commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`)
+ VALUES
+ (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, 0, CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants'),
+ (2, 'Farmer King', 'The farmer', 4000020002, 1, '87945234L', 1, 0, CURDATE(), 1, 'supplier address 2', 'SILLA', 2, 43022, 1, 2, 10, 93, 2, 8, 18, 'animals'),
+ (442, 'Verdnatura Levante SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, 0, CURDATE(), 1, 'supplier address 3', 'SILLA', 1, 43022, 1, 2, 15, 6, 9, 3, 18, 'flowerPlants');
INSERT INTO `vn`.`supplierContact`(`id`, `supplierFk`, `phone`, `mobile`, `email`, `observation`, `name`)
VALUES
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index 21fd2294d..657bb0eb4 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -1,4 +1,4 @@
--- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for Linux (x86_64)
+-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for Linux (x86_64)
--
-- Host: test-db.verdnatura.es Database: account
-- ------------------------------------------------------
@@ -886,52 +886,52 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `passwordGenerate`() RETURNS text CHARSET utf8 COLLATE utf8_unicode_ci
READS SQL DATA
-BEGIN
-/**
- * Generates a random password that meets the minimum requirements.
- *
- * @return Generated password
- */
- DECLARE vMinLength TINYINT;
- DECLARE vMinAlpha TINYINT;
- DECLARE vMinUpper TINYINT;
- DECLARE vMinDigits TINYINT;
- DECLARE vMinPunct TINYINT;
- DECLARE vAlpha TINYINT DEFAULT 0;
- DECLARE vUpper TINYINT DEFAULT 0;
- DECLARE vDigits TINYINT DEFAULT 0;
- DECLARE vPunct TINYINT DEFAULT 0;
- DECLARE vRandIndex INT;
- DECLARE vPwd TEXT DEFAULT '';
-
- DECLARE vAlphaChars TEXT DEFAULT 'abcdefghijklmnopqrstuvwxyz';
- DECLARE vUpperChars TEXT DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- DECLARE vDigitChars TEXT DEFAULT '1234567890';
- DECLARE vPunctChars TEXT DEFAULT '!$%&()=.';
-
- SELECT length, nAlpha, nUpper, nDigits, nPunct
- INTO vMinLength, vMinAlpha, vMinUpper, vMinDigits, vMinPunct FROM userPassword;
-
- WHILE LENGTH(vPwd) < vMinLength OR vAlpha < vMinAlpha
- OR vUpper < vMinUpper OR vDigits < vMinDigits OR vPunct < vMinPunct DO
- SET vRandIndex = FLOOR((RAND() * 4) + 1);
-
- CASE
- WHEN vRandIndex = 1 THEN
- SET vPwd = CONCAT(vPwd, SUBSTRING(vAlphaChars, FLOOR((RAND() * 26) + 1), 1));
- SET vAlpha = vAlpha + 1;
- WHEN vRandIndex = 2 THEN
- SET vPwd = CONCAT(vPwd, SUBSTRING(vUpperChars, FLOOR((RAND() * 26) + 1), 1));
- SET vUpper = vUpper + 1;
- WHEN vRandIndex = 3 THEN
- SET vPwd = CONCAT(vPwd, SUBSTRING(vDigitChars, FLOOR((RAND() * 10) + 1), 1));
- SET vDigits = vDigits + 1;
- WHEN vRandIndex = 4 THEN
- SET vPwd = CONCAT(vPwd, SUBSTRING(vPunctChars, FLOOR((RAND() * LENGTH(vPunctChars)) + 1), 1));
- SET vPunct = vPunct + 1;
- END CASE;
- END WHILE;
- RETURN vPwd;
+BEGIN
+/**
+ * Generates a random password that meets the minimum requirements.
+ *
+ * @return Generated password
+ */
+ DECLARE vMinLength TINYINT;
+ DECLARE vMinAlpha TINYINT;
+ DECLARE vMinUpper TINYINT;
+ DECLARE vMinDigits TINYINT;
+ DECLARE vMinPunct TINYINT;
+ DECLARE vAlpha TINYINT DEFAULT 0;
+ DECLARE vUpper TINYINT DEFAULT 0;
+ DECLARE vDigits TINYINT DEFAULT 0;
+ DECLARE vPunct TINYINT DEFAULT 0;
+ DECLARE vRandIndex INT;
+ DECLARE vPwd TEXT DEFAULT '';
+
+ DECLARE vAlphaChars TEXT DEFAULT 'abcdefghijklmnopqrstuvwxyz';
+ DECLARE vUpperChars TEXT DEFAULT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ DECLARE vDigitChars TEXT DEFAULT '1234567890';
+ DECLARE vPunctChars TEXT DEFAULT '!$%&()=.';
+
+ SELECT length, nAlpha, nUpper, nDigits, nPunct
+ INTO vMinLength, vMinAlpha, vMinUpper, vMinDigits, vMinPunct FROM userPassword;
+
+ WHILE LENGTH(vPwd) < vMinLength OR vAlpha < vMinAlpha
+ OR vUpper < vMinUpper OR vDigits < vMinDigits OR vPunct < vMinPunct DO
+ SET vRandIndex = FLOOR((RAND() * 4) + 1);
+
+ CASE
+ WHEN vRandIndex = 1 THEN
+ SET vPwd = CONCAT(vPwd, SUBSTRING(vAlphaChars, FLOOR((RAND() * 26) + 1), 1));
+ SET vAlpha = vAlpha + 1;
+ WHEN vRandIndex = 2 THEN
+ SET vPwd = CONCAT(vPwd, SUBSTRING(vUpperChars, FLOOR((RAND() * 26) + 1), 1));
+ SET vUpper = vUpper + 1;
+ WHEN vRandIndex = 3 THEN
+ SET vPwd = CONCAT(vPwd, SUBSTRING(vDigitChars, FLOOR((RAND() * 10) + 1), 1));
+ SET vDigits = vDigits + 1;
+ WHEN vRandIndex = 4 THEN
+ SET vPwd = CONCAT(vPwd, SUBSTRING(vPunctChars, FLOOR((RAND() * LENGTH(vPunctChars)) + 1), 1));
+ SET vPunct = vPunct + 1;
+ END CASE;
+ END WHILE;
+ RETURN vPwd;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -1024,11 +1024,11 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `userGetNameFromId__`(vSelf INT) RETURNS varchar(30) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
-BEGIN
-/**
- * @deprecated Use user_getNameFromId();
- */
- RETURN user_getNameFromId(vSelf);
+BEGIN
+/**
+ * @deprecated Use user_getNameFromId();
+ */
+ RETURN user_getNameFromId(vSelf);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -1093,22 +1093,22 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `user_getMysqlRole`(vUserName VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
-BEGIN
-/**
- * From a username, it returns the associated MySQL wich should be used when
- * using external authentication systems.
- *
- * @param vUserName The user name
- * @return The associated MySQL role
- */
- DECLARE vRole VARCHAR(255);
-
- SELECT CONCAT(IF(r.hasLogin, 'z-', ''), r.name) INTO vRole
- FROM role r
- JOIN user u ON u.role = r.id
- WHERE u.name = vUserName;
-
- RETURN vRole;
+BEGIN
+/**
+ * From a username, it returns the associated MySQL wich should be used when
+ * using external authentication systems.
+ *
+ * @param vUserName The user name
+ * @return The associated MySQL role
+ */
+ DECLARE vRole VARCHAR(255);
+
+ SELECT CONCAT(IF(r.hasLogin, 'z-', ''), r.name) INTO vRole
+ FROM role r
+ JOIN user u ON u.role = r.id
+ WHERE u.name = vUserName;
+
+ RETURN vRole;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -1127,20 +1127,20 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `user_getNameFromId`(vSelf INT) RETURNS varchar(30) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
-BEGIN
-/**
- * Gets user name from it's id.
- *
- * @param vSelf The user id
- * @return The user name
- */
- DECLARE vName VARCHAR(30);
-
- SELECT `name` INTO vName
- FROM user
- WHERE id = vSelf;
-
- RETURN vName;
+BEGIN
+/**
+ * Gets user name from it's id.
+ *
+ * @param vSelf The user id
+ * @return The user name
+ */
+ DECLARE vName VARCHAR(30);
+
+ SELECT `name` INTO vName
+ FROM user
+ WHERE id = vSelf;
+
+ RETURN vName;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -4968,16 +4968,16 @@ BEGIN
* La tabla mana_spellers es una caché
*
*/
-
- UPDATE mana_spellers me
- JOIN
- (SELECT Id_Trabajador, FLOOR(SUM(importe)/12) as pesoCarteraMensual
- FROM bs.vendedores
- WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE())
- GROUP BY Id_Trabajador
- ) lastYearSales USING(Id_Trabajador)
- SET me.prices_modifier_rate = GREATEST(me.minRate,LEAST(me.maxRate,ROUND(- me.used/lastYearSales.pesoCarteraMensual,3))) ;
-
+
+ UPDATE mana_spellers me
+ JOIN
+ (SELECT Id_Trabajador, FLOOR(SUM(importe)/12) as pesoCarteraMensual
+ FROM bs.vendedores
+ WHERE año * 100 + mes >= (YEAR(CURDATE()) -1) * 100 + MONTH(CURDATE())
+ GROUP BY Id_Trabajador
+ ) lastYearSales USING(Id_Trabajador)
+ SET me.prices_modifier_rate = GREATEST(me.minRate,LEAST(me.maxRate,ROUND(- me.used/lastYearSales.pesoCarteraMensual,3))) ;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -5394,46 +5394,46 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`z-developer`@`%` PROCEDURE `saleGraphic`(vItemFk INT,
- vTypeFk INT,
- vCategoryFk INT,
- vFromDate DATE,
- vToDate DATE,
+CREATE DEFINER=`z-developer`@`%` PROCEDURE `saleGraphic`(vItemFk INT,
+ vTypeFk INT,
+ vCategoryFk INT,
+ vFromDate DATE,
+ vToDate DATE,
vProducerFk INT)
-BEGIN
-
- DECLARE vFromDateLastYear DATE;
- DECLARE vToDateLastYear DATE;
- DECLARE vFromDateTwoYearsAgo DATE;
- DECLARE vToDateTwoYearsAgo DATE;
-
- SET vItemFk = IFNULL(vItemFk,0);
- SET vTypeFk = IFNULL(vTypeFk, 0);
- SET vCategoryFk = IFNULL(vCategoryFk,0);
- SET vFromDate = IFNULL(vFromDate,CURDATE());
- SET vToDate = IFNULL(vToDate,CURDATE());
- SET vProducerFk = IFNULL(vProducerFk,0);
-
- SET vFromDateLastYear = TIMESTAMPADD(YEAR,-1,vFromDate);
- SET vToDateLastYear = TIMESTAMPADD(YEAR,-1,vToDate);
- SET vFromDateTwoYearsAgo = TIMESTAMPADD(YEAR,-2,vFromDate);
- SET vToDateTwoYearsAgo = TIMESTAMPADD(YEAR,-2,vToDate);
-
- SELECT s.quantity, CAST(v.importe AS DECIMAL(10,0)) importe, v.fecha
- FROM bs.ventas v
- JOIN vn.sale s ON s.id = v.Id_Movimiento
- 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
- WHERE vItemFk IN (i.id, 0)
- AND vTypeFk IN (i.typeFk, 0)
- AND vCategoryFk IN (it.categoryFk, 0)
- AND vProducerFk IN (i.producerFk, 0)
- AND (v.fecha BETWEEN vFromDate AND vToDate
- OR v.fecha BETWEEN vFromDateLastYear AND vToDateLastYear
- OR v.fecha BETWEEN vFromDateTwoYearsAgo AND vToDateTwoYearsAgo
- );
-
+BEGIN
+
+ DECLARE vFromDateLastYear DATE;
+ DECLARE vToDateLastYear DATE;
+ DECLARE vFromDateTwoYearsAgo DATE;
+ DECLARE vToDateTwoYearsAgo DATE;
+
+ SET vItemFk = IFNULL(vItemFk,0);
+ SET vTypeFk = IFNULL(vTypeFk, 0);
+ SET vCategoryFk = IFNULL(vCategoryFk,0);
+ SET vFromDate = IFNULL(vFromDate,CURDATE());
+ SET vToDate = IFNULL(vToDate,CURDATE());
+ SET vProducerFk = IFNULL(vProducerFk,0);
+
+ SET vFromDateLastYear = TIMESTAMPADD(YEAR,-1,vFromDate);
+ SET vToDateLastYear = TIMESTAMPADD(YEAR,-1,vToDate);
+ SET vFromDateTwoYearsAgo = TIMESTAMPADD(YEAR,-2,vFromDate);
+ SET vToDateTwoYearsAgo = TIMESTAMPADD(YEAR,-2,vToDate);
+
+ SELECT s.quantity, CAST(v.importe AS DECIMAL(10,0)) importe, v.fecha
+ FROM bs.ventas v
+ JOIN vn.sale s ON s.id = v.Id_Movimiento
+ 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
+ WHERE vItemFk IN (i.id, 0)
+ AND vTypeFk IN (i.typeFk, 0)
+ AND vCategoryFk IN (it.categoryFk, 0)
+ AND vProducerFk IN (i.producerFk, 0)
+ AND (v.fecha BETWEEN vFromDate AND vToDate
+ OR v.fecha BETWEEN vFromDateLastYear AND vToDateLastYear
+ OR v.fecha BETWEEN vFromDateTwoYearsAgo AND vToDateTwoYearsAgo
+ );
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7119,7 +7119,7 @@ CREATE TABLE `cache_calc` (
KEY `cache_id` (`cache_id`),
KEY `cacheName` (`cacheName`),
KEY `expires` (`expires`)
-) 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 */;
--
@@ -7133,7 +7133,7 @@ CREATE TABLE `cache_valid` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`valid` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+) ENGINE=MEMORYDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -7337,146 +7337,146 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `availableNoRaids_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDate` DATE)
-proc: BEGIN
- DECLARE vStartDate DATE;
- DECLARE vEndDate DATETIME;
- DECLARE vReserveDate DATETIME;
- DECLARE vParams CHAR(100);
- DECLARE vInventoryDate DATE;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- CALL cache_calc_unlock (vCalc);
- RESIGNAL;
- END;
-
- IF vDate < CURDATE() THEN
- LEAVE proc;
- END IF;
-
- CALL vn.itemStock (vWarehouse, vDate, NULL);
-
- SET vParams = CONCAT_WS('/', vWarehouse, vDate);
- CALL cache_calc_start (vCalc, vRefresh, 'availableNoRaids', vParams);
-
- IF !vRefresh THEN
- LEAVE proc;
- END IF;
-
- -- Calcula algunos parámetros necesarios
-
- SET vStartDate = TIMESTAMP(vDate, '00:00:00');
- SET vEndDate = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDate), '23:59:59');
-
- SELECT inventoried INTO vInventoryDate FROM vn.config;
-
- SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate
- FROM hedera.orderConfig;
-
- -- Calcula el ultimo dia de vida para cada producto
-
- DROP TEMPORARY TABLE IF EXISTS item_range;
- CREATE TEMPORARY TABLE item_range
- (PRIMARY KEY (item_id))
- ENGINE = MEMORY
- SELECT c.item_id, IF(it.life IS NULL, NULL,
- TIMESTAMP(TIMESTAMPADD(DAY, it.life, c.landing), '23:59:59')) AS date_end
- FROM (
- SELECT b.itemFk item_id, MAX(t.landed) landing
- FROM vn.buy b
- JOIN vn.entry e ON b.entryFk = e.id
- JOIN vn.travel t ON t.id = e.travelFk
- JOIN vn.warehouse w ON w.id = t.warehouseInFk
- WHERE t.landed BETWEEN vInventoryDate AND vStartDate
- AND t.warehouseInFk = vWarehouse
- AND NOT e.isInventory
- AND NOT e.isRaid
- GROUP BY b.itemFk
- ) c
- JOIN vn.item i ON i.id = c.item_id
- JOIN vn.itemType it ON it.id = i.typeFk
- HAVING date_end >= vStartDate OR date_end IS NULL;
-
- -- Replica la tabla item_range para poder usarla varias veces en la misma consulta
-
- DROP TEMPORARY TABLE IF EXISTS item_range_copy1;
- CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range;
- INSERT INTO item_range_copy1
- SELECT * FROM item_range;
-
- DROP TEMPORARY TABLE IF EXISTS item_range_copy2;
- CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range;
- INSERT INTO item_range_copy2
- SELECT * FROM item_range;
-
- DROP TEMPORARY TABLE IF EXISTS item_range_copy3;
- CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range;
- INSERT INTO item_range_copy3
- SELECT * FROM item_range;
-
- DROP TEMPORARY TABLE IF EXISTS item_range_copy4;
- CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range;
- INSERT INTO item_range_copy4
- SELECT * FROM item_range;
-
- -- Calcula el ATP
-
- DELETE FROM availableNoRaids WHERE calc_id = vCalc;
-
- INSERT INTO availableNoRaids (calc_id, item_id, available)
- SELECT vCalc, t.item_id, SUM(stock) amount FROM (
- SELECT il.itemFk AS item_id, stock
- FROM tmp.itemList il
- JOIN item_range ir ON ir.item_id = il.itemFk
- UNION ALL
- SELECT t.item_id, minacum(dt, amount, vDate) AS available FROM (
- SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount FROM (
- SELECT i.itemFk, i.shipped AS dat, i.quantity
- FROM vn.itemTicketOut i
- JOIN item_range_copy1 ir ON ir.item_id = i.itemFk
- WHERE i.shipped >= vStartDate
- AND (ir.date_end IS NULL OR i.shipped <= ir.date_end)
- AND i.warehouseFk = vWarehouse
- UNION ALL
- SELECT i.itemFk, i.landed AS dat, i.quantity
- FROM vn.itemEntryIn i
- JOIN item_range_copy2 ir ON ir.item_id = i.itemFk
- WHERE i.landed >= vStartDate
- AND (ir.date_end IS NULL OR i.landed <= ir.date_end)
- AND i.warehouseInFk = vWarehouse
- AND i.isVirtualStock = FALSE
- UNION ALL
- SELECT i.itemFk, i.shipped AS dat, i.quantity
- FROM vn.itemEntryOut i
- JOIN item_range_copy3 ir ON ir.item_id = i.itemFk
- WHERE i.shipped >= vStartDate
- AND (ir.date_end IS NULL OR i.shipped <= ir.date_end)
- AND i.warehouseOutFk = vWarehouse
- UNION ALL
- SELECT r.item_id, r.shipment, -r.amount
- FROM hedera.order_row r
- JOIN hedera.`order` o ON o.id = r.order_id
- JOIN item_range_copy4 ir ON ir.item_id = r.item_id
- WHERE r.shipment >= vStartDate
- AND (ir.date_end IS NULL OR r.shipment <= ir.date_end)
- AND r.warehouse_id = vWarehouse
- AND r.created >= vReserveDate
- AND NOT o.confirmed
- ) t
- GROUP BY item_id, dt
- ) t
- GROUP BY t.item_id
- ) t GROUP BY t.item_id;
-
- DROP TEMPORARY TABLE IF EXISTS
- tmp.itemList
- ,item_range
- ,item_range_copy1
- ,item_range_copy2
- ,item_range_copy3
- ,item_range_copy4;
-
- CALL cache_calc_end (vCalc);
+proc: BEGIN
+ DECLARE vStartDate DATE;
+ DECLARE vEndDate DATETIME;
+ DECLARE vReserveDate DATETIME;
+ DECLARE vParams CHAR(100);
+ DECLARE vInventoryDate DATE;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ CALL cache_calc_unlock (vCalc);
+ RESIGNAL;
+ END;
+
+ IF vDate < CURDATE() THEN
+ LEAVE proc;
+ END IF;
+
+ CALL vn.itemStock (vWarehouse, vDate, NULL);
+
+ SET vParams = CONCAT_WS('/', vWarehouse, vDate);
+ CALL cache_calc_start (vCalc, vRefresh, 'availableNoRaids', vParams);
+
+ IF !vRefresh THEN
+ LEAVE proc;
+ END IF;
+
+ -- Calcula algunos parámetros necesarios
+
+ SET vStartDate = TIMESTAMP(vDate, '00:00:00');
+ SET vEndDate = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDate), '23:59:59');
+
+ SELECT inventoried INTO vInventoryDate FROM vn.config;
+
+ SELECT SUBTIME(NOW(), reserveTime) INTO vReserveDate
+ FROM hedera.orderConfig;
+
+ -- Calcula el ultimo dia de vida para cada producto
+
+ DROP TEMPORARY TABLE IF EXISTS item_range;
+ CREATE TEMPORARY TABLE item_range
+ (PRIMARY KEY (item_id))
+ ENGINE = MEMORY
+ SELECT c.item_id, IF(it.life IS NULL, NULL,
+ TIMESTAMP(TIMESTAMPADD(DAY, it.life, c.landing), '23:59:59')) AS date_end
+ FROM (
+ SELECT b.itemFk item_id, MAX(t.landed) landing
+ FROM vn.buy b
+ JOIN vn.entry e ON b.entryFk = e.id
+ JOIN vn.travel t ON t.id = e.travelFk
+ JOIN vn.warehouse w ON w.id = t.warehouseInFk
+ WHERE t.landed BETWEEN vInventoryDate AND vStartDate
+ AND t.warehouseInFk = vWarehouse
+ AND NOT e.isInventory
+ AND NOT e.isRaid
+ GROUP BY b.itemFk
+ ) c
+ JOIN vn.item i ON i.id = c.item_id
+ JOIN vn.itemType it ON it.id = i.typeFk
+ HAVING date_end >= vStartDate OR date_end IS NULL;
+
+ -- Replica la tabla item_range para poder usarla varias veces en la misma consulta
+
+ DROP TEMPORARY TABLE IF EXISTS item_range_copy1;
+ CREATE TEMPORARY TABLE item_range_copy1 LIKE item_range;
+ INSERT INTO item_range_copy1
+ SELECT * FROM item_range;
+
+ DROP TEMPORARY TABLE IF EXISTS item_range_copy2;
+ CREATE TEMPORARY TABLE item_range_copy2 LIKE item_range;
+ INSERT INTO item_range_copy2
+ SELECT * FROM item_range;
+
+ DROP TEMPORARY TABLE IF EXISTS item_range_copy3;
+ CREATE TEMPORARY TABLE item_range_copy3 LIKE item_range;
+ INSERT INTO item_range_copy3
+ SELECT * FROM item_range;
+
+ DROP TEMPORARY TABLE IF EXISTS item_range_copy4;
+ CREATE TEMPORARY TABLE item_range_copy4 LIKE item_range;
+ INSERT INTO item_range_copy4
+ SELECT * FROM item_range;
+
+ -- Calcula el ATP
+
+ DELETE FROM availableNoRaids WHERE calc_id = vCalc;
+
+ INSERT INTO availableNoRaids (calc_id, item_id, available)
+ SELECT vCalc, t.item_id, SUM(stock) amount FROM (
+ SELECT il.itemFk AS item_id, stock
+ FROM tmp.itemList il
+ JOIN item_range ir ON ir.item_id = il.itemFk
+ UNION ALL
+ SELECT t.item_id, minacum(dt, amount, vDate) AS available FROM (
+ SELECT itemFk AS item_id, DATE(dat) dt, SUM(quantity) amount FROM (
+ SELECT i.itemFk, i.shipped AS dat, i.quantity
+ FROM vn.itemTicketOut i
+ JOIN item_range_copy1 ir ON ir.item_id = i.itemFk
+ WHERE i.shipped >= vStartDate
+ AND (ir.date_end IS NULL OR i.shipped <= ir.date_end)
+ AND i.warehouseFk = vWarehouse
+ UNION ALL
+ SELECT i.itemFk, i.landed AS dat, i.quantity
+ FROM vn.itemEntryIn i
+ JOIN item_range_copy2 ir ON ir.item_id = i.itemFk
+ WHERE i.landed >= vStartDate
+ AND (ir.date_end IS NULL OR i.landed <= ir.date_end)
+ AND i.warehouseInFk = vWarehouse
+ AND i.isVirtualStock = FALSE
+ UNION ALL
+ SELECT i.itemFk, i.shipped AS dat, i.quantity
+ FROM vn.itemEntryOut i
+ JOIN item_range_copy3 ir ON ir.item_id = i.itemFk
+ WHERE i.shipped >= vStartDate
+ AND (ir.date_end IS NULL OR i.shipped <= ir.date_end)
+ AND i.warehouseOutFk = vWarehouse
+ UNION ALL
+ SELECT r.item_id, r.shipment, -r.amount
+ FROM hedera.order_row r
+ JOIN hedera.`order` o ON o.id = r.order_id
+ JOIN item_range_copy4 ir ON ir.item_id = r.item_id
+ WHERE r.shipment >= vStartDate
+ AND (ir.date_end IS NULL OR r.shipment <= ir.date_end)
+ AND r.warehouse_id = vWarehouse
+ AND r.created >= vReserveDate
+ AND NOT o.confirmed
+ ) t
+ GROUP BY item_id, dt
+ ) t
+ GROUP BY t.item_id
+ ) t GROUP BY t.item_id;
+
+ DROP TEMPORARY TABLE IF EXISTS
+ tmp.itemList
+ ,item_range
+ ,item_range_copy1
+ ,item_range_copy2
+ ,item_range_copy3
+ ,item_range_copy4;
+
+ CALL cache_calc_end (vCalc);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7695,9 +7695,9 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `cacheCalc_clean`()
-BEGIN
- DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW());
- DELETE FROM cache_calc WHERE expires < vCleanTime;
+BEGIN
+ DECLARE vCleanTime DATETIME DEFAULT TIMESTAMPADD(MINUTE, -5, NOW());
+ DELETE FROM cache_calc WHERE expires < vCleanTime;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7715,27 +7715,27 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_end`(IN `v_calc` INT)
-BEGIN
- DECLARE v_cache_name VARCHAR(255);
- DECLARE v_params VARCHAR(255);
-
- -- Libera el bloqueo y actualiza la fecha de ultimo refresco.
-
- UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id
- SET
- cc.last_refresh = NOW(),
- cc.expires = ADDTIME(NOW(), c.lifetime),
- cc.connection_id = NULL
- WHERE cc.id = v_calc;
-
- SELECT c.name, ca.params INTO v_cache_name, v_params
- FROM cache c
- JOIN cache_calc ca ON c.id = ca.cache_id
- WHERE ca.id = v_calc;
-
- IF v_cache_name IS NOT NULL THEN
- DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
- END IF;
+BEGIN
+ DECLARE v_cache_name VARCHAR(255);
+ DECLARE v_params VARCHAR(255);
+
+ -- Libera el bloqueo y actualiza la fecha de ultimo refresco.
+
+ UPDATE cache_calc cc JOIN cache c ON c.id = cc.cache_id
+ SET
+ cc.last_refresh = NOW(),
+ cc.expires = ADDTIME(NOW(), c.lifetime),
+ cc.connection_id = NULL
+ WHERE cc.id = v_calc;
+
+ SELECT c.name, ca.params INTO v_cache_name, v_params
+ FROM cache c
+ JOIN cache_calc ca ON c.id = ca.cache_id
+ WHERE ca.id = v_calc;
+
+ IF v_cache_name IS NOT NULL THEN
+ DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
+ END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7753,91 +7753,91 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_start`(OUT `v_calc` INT, INOUT `v_refresh` INT, IN `v_cache_name` VARCHAR(50), IN `v_params` VARCHAR(100))
-proc: BEGIN
- DECLARE v_valid BOOL;
- DECLARE v_lock_id VARCHAR(100);
- DECLARE v_cache_id INT;
- DECLARE v_expires DATETIME;
- DECLARE v_clean_time DATETIME;
-
- DECLARE EXIT HANDLER FOR SQLEXCEPTION
- BEGIN
- IF v_lock_id IS NOT NULL THEN
- DO RELEASE_LOCK(v_lock_id);
- END IF;
-
- RESIGNAL;
- END;
-
- SET v_params = IFNULL(v_params, '');
-
- -- Si el servidor se ha reiniciado invalida todos los calculos.
-
- SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid;
-
- IF !v_valid
+proc: BEGIN
+ DECLARE v_valid BOOL;
+ DECLARE v_lock_id VARCHAR(100);
+ DECLARE v_cache_id INT;
+ DECLARE v_expires DATETIME;
+ DECLARE v_clean_time DATETIME;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ BEGIN
+ IF v_lock_id IS NOT NULL THEN
+ DO RELEASE_LOCK(v_lock_id);
+ END IF;
+
+ RESIGNAL;
+ END;
+
+ SET v_params = IFNULL(v_params, '');
+
+ -- Si el servidor se ha reiniciado invalida todos los calculos.
+
+ SELECT COUNT(*) > 0 INTO v_valid FROM cache_valid;
+
+ IF !v_valid
+ THEN
+ DELETE FROM cache_calc;
+ INSERT INTO cache_valid (valid) VALUES (TRUE);
+ END IF;
+
+ -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia.
+
+ SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params);
+
+ IF !GET_LOCK(v_lock_id, 30)
+ THEN
+ SET v_calc = NULL;
+ SET v_refresh = FALSE;
+ LEAVE proc;
+ END IF;
+
+ -- Comprueba si el calculo solicitado existe y esta actualizado.
+
+ SELECT c.id, ca.id, ca.expires
+ INTO v_cache_id, v_calc, v_expires
+ FROM cache c
+ LEFT JOIN cache_calc ca
+ ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci'
+ WHERE c.name = v_cache_name COLLATE 'utf8_general_ci';
+
+ -- Si existe una calculo valido libera el bloqueo y devuelve su identificador.
+
+ IF !v_refresh AND NOW() < v_expires
+ THEN
+ DO RELEASE_LOCK(v_lock_id);
+ SET v_refresh = FALSE;
+ LEAVE proc;
+ END IF;
+
+ -- Si el calculo no existe le crea una entrada en la tabla de calculos.
+
+ IF v_calc IS NULL
THEN
- DELETE FROM cache_calc;
- INSERT INTO cache_valid (valid) VALUES (TRUE);
- END IF;
-
- -- Obtiene un bloqueo exclusivo para que no haya problemas de concurrencia.
-
- SET v_lock_id = CONCAT_WS('/', v_cache_name, v_params);
-
- IF !GET_LOCK(v_lock_id, 30)
- THEN
- SET v_calc = NULL;
- SET v_refresh = FALSE;
- LEAVE proc;
- END IF;
-
- -- Comprueba si el calculo solicitado existe y esta actualizado.
-
- SELECT c.id, ca.id, ca.expires
- INTO v_cache_id, v_calc, v_expires
- FROM cache c
- LEFT JOIN cache_calc ca
- ON ca.cache_id = c.id AND ca.params = v_params COLLATE 'utf8_general_ci'
- WHERE c.name = v_cache_name COLLATE 'utf8_general_ci';
-
- -- Si existe una calculo valido libera el bloqueo y devuelve su identificador.
-
- IF !v_refresh AND NOW() < v_expires
- THEN
- DO RELEASE_LOCK(v_lock_id);
- SET v_refresh = FALSE;
- LEAVE proc;
- END IF;
-
- -- Si el calculo no existe le crea una entrada en la tabla de calculos.
-
- IF v_calc IS NULL
- THEN
- -- call util.debugAdd(concat('if start ', v_lock_id) ,v_refresh);
- INSERT INTO cache_calc SET
- cache_id = v_cache_id,
- cacheName = v_cache_name,
- params = v_params,
- last_refresh = NULL,
- expires = NULL,
- connection_id = CONNECTION_ID();
- -- call util.debugAdd(concat('if end ', v_lock_id),v_refresh);
- SET v_calc = LAST_INSERT_ID();
+ -- call util.debugAdd(concat('if start ', v_lock_id) ,v_refresh);
+ INSERT INTO cache_calc SET
+ cache_id = v_cache_id,
+ cacheName = v_cache_name,
+ params = v_params,
+ last_refresh = NULL,
+ expires = NULL,
+ connection_id = CONNECTION_ID();
+ -- call util.debugAdd(concat('if end ', v_lock_id),v_refresh);
+ SET v_calc = LAST_INSERT_ID();
ELSE
- -- call util.debugAdd(concat('else start ', v_lock_id) ,v_refresh);
- UPDATE cache_calc
- SET
- last_refresh = NULL,
- expires = NULL,
- connection_id = CONNECTION_ID()
+ -- call util.debugAdd(concat('else start ', v_lock_id) ,v_refresh);
+ UPDATE cache_calc
+ SET
+ last_refresh = NULL,
+ expires = NULL,
+ connection_id = CONNECTION_ID()
WHERE id = v_calc;
- -- call util.debugAdd(concat('else end ', v_lock_id) ,v_refresh);
- END IF;
-
- -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador.
-
- SET v_refresh = TRUE;
+ -- call util.debugAdd(concat('else end ', v_lock_id) ,v_refresh);
+ END IF;
+
+ -- Si se debe recalcular mantiene el bloqueo y devuelve su identificador.
+
+ SET v_refresh = TRUE;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7855,24 +7855,24 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `cache_calc_unlock`(IN `v_calc` INT)
-proc: BEGIN
- DECLARE v_cache_name VARCHAR(50);
- DECLARE v_params VARCHAR(100);
-
- IF v_calc IS NULL THEN
- LEAVE proc;
- END IF;
-
- SELECT c.name, ca.params INTO v_cache_name, v_params
- FROM cache c
- JOIN cache_calc ca ON c.id = ca.cache_id
- WHERE ca.id = v_calc;
-
- DELETE FROM cache_calc WHERE id = v_calc;
-
- IF v_cache_name IS NOT NULL THEN
- DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
- END IF;
+proc: BEGIN
+ DECLARE v_cache_name VARCHAR(50);
+ DECLARE v_params VARCHAR(100);
+
+ IF v_calc IS NULL THEN
+ LEAVE proc;
+ END IF;
+
+ SELECT c.name, ca.params INTO v_cache_name, v_params
+ FROM cache c
+ JOIN cache_calc ca ON c.id = ca.cache_id
+ WHERE ca.id = v_calc;
+
+ DELETE FROM cache_calc WHERE id = v_calc;
+
+ IF v_cache_name IS NOT NULL THEN
+ DO RELEASE_LOCK(CONCAT_WS('/', v_cache_name, IFNULL(v_params, '')));
+ END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7891,9 +7891,9 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `cache_clean`()
NO SQL
-BEGIN
- CALL available_clean;
- CALL visible_clean;
+BEGIN
+ CALL available_clean;
+ CALL visible_clean;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -7911,13 +7911,13 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `clean`()
-BEGIN
-
- DECLARE vDateShort DATETIME;
-
- SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE());
-
- DELETE FROM cache.departure_limit WHERE Fecha < vDateShort;
+BEGIN
+
+ DECLARE vDateShort DATETIME;
+
+ SET vDateShort = TIMESTAMPADD(MONTH, -1, CURDATE());
+
+ DELETE FROM cache.departure_limit WHERE Fecha < vDateShort;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -8861,9 +8861,13 @@ DROP TABLE IF EXISTS `genus`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `genus` (
- `id` mediumint(8) unsigned NOT NULL,
- `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
- PRIMARY KEY (`id`)
+ `genus_id` mediumint(8) unsigned NOT NULL,
+ `latin_genus_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
+ `entry_date` date DEFAULT NULL,
+ `expiry_date` date DEFAULT NULL,
+ `change_date_time` datetime DEFAULT NULL,
+ `isHazard` tinyint(1) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`genus_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='/tmp/floricode/florecompc2/FG130916.txt';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -9163,7 +9167,7 @@ DROP TABLE IF EXISTS `plant`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `plant` (
`plant_id` mediumint(8) unsigned NOT NULL,
- `id` mediumint(8) unsigned NOT NULL,
+ `genus_id` mediumint(8) unsigned NOT NULL,
`specie_id` mediumint(8) unsigned DEFAULT NULL,
`entry_date` date DEFAULT NULL,
`expiry_date` date DEFAULT NULL,
@@ -9239,6 +9243,7 @@ BEGIN
DECLARE vError VARCHAR(100) DEFAULT 'Orderregel niet meer teruggevonden op basis van de orderps';
DECLARE vVmpIdError INT DEFAULT 7;
DECLARE vVmpFk INT;
+ DECLARE vSupplyResponseNumberOfUnits INT;
SELECT sr.vmpID INTO vVmpFk
FROM edi.supplyResponse sr
@@ -9254,6 +9259,17 @@ BEGIN
SET NEW.OrderStatus = 2;
END IF;
+
+ -- Error de disponible menor de lo solicitado
+ IF NEW.error LIKE 'error2602%' THEN
+
+ SELECT NumberOfUnits INTO vSupplyResponseNumberOfUnits
+ FROM edi.supplyResponse sr
+ WHERE sr.ID = NEW.supplyResponseID;
+
+ SET NEW.error = CONCAT('(',vSupplyResponseNumberOfUnits,') ', NEW.error);
+
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9354,7 +9370,7 @@ DROP TABLE IF EXISTS `specie`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `specie` (
`specie_id` mediumint(8) unsigned NOT NULL,
- `id` mediumint(8) unsigned NOT NULL,
+ `genus_id` mediumint(8) unsigned NOT NULL,
`latin_species_name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`entry_date` date DEFAULT NULL,
`expiry_date` date DEFAULT NULL,
@@ -9579,22 +9595,22 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` FUNCTION `imageName`(vPictureReference VARCHAR(255)) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
-BEGIN
-
- SET vPictureReference = REPLACE(vPictureReference,'.','');
-
- SET vPictureReference = REPLACE(vPictureReference,'/','');
-
- SET vPictureReference = REPLACE(vPictureReference,'%','');
-
- SET vPictureReference = REPLACE(vPictureReference,':','');
-
- SET vPictureReference = REPLACE(vPictureReference,'?','');
-
- SET vPictureReference = REPLACE(vPictureReference,'=','');
-
- RETURN vPictureReference;
-
+BEGIN
+
+ SET vPictureReference = REPLACE(vPictureReference,'.','');
+
+ SET vPictureReference = REPLACE(vPictureReference,'/','');
+
+ SET vPictureReference = REPLACE(vPictureReference,'%','');
+
+ SET vPictureReference = REPLACE(vPictureReference,':','');
+
+ SET vPictureReference = REPLACE(vPictureReference,'?','');
+
+ SET vPictureReference = REPLACE(vPictureReference,'=','');
+
+ RETURN vPictureReference;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -9901,154 +9917,154 @@ CREATE DEFINER=`root`@`%` PROCEDURE `exchange_new`(
IN `vAuction` SMALLINT,
IN `vPackage` INT,
IN `vPutOrderFk` INT)
-BEGIN
+BEGIN
/**
* Adds a new exchange, generates it's barcode and
* inserts/updates the transaction. When the referenced
* transaction exists as provisional, updates it with
- * the new values.
- */
- DECLARE vEkt INT;
- DECLARE vRewriteKop INT DEFAULT NULL;
- DECLARE vBarcode CHAR(15) DEFAULT NULL;
- DECLARE vIsDuplicated BOOL;
+ * the new values.
+ */
+ DECLARE vEkt INT;
+ DECLARE vRewriteKop INT DEFAULT NULL;
+ DECLARE vBarcode CHAR(15) DEFAULT NULL;
+ DECLARE vIsDuplicated BOOL;
DECLARE vUpdateExistent BOOL DEFAULT FALSE;
- DECLARE duplicateKey CONDITION FOR 1062;
+ DECLARE duplicateKey CONDITION FOR 1062;
+
+ DECLARE CONTINUE HANDLER FOR duplicateKey
+ SET vIsDuplicated = TRUE;
+
+ -- Generates the barcode
+
+ IF vAgj != 0 AND vAgj IS NOT NULL
+ THEN
+ SET vBarcode = CONCAT(
+ LPAD(vAuction, 2, 0),
+ LPAD(IFNULL(vClock, 99), 2, 0),
+ LPAD(DAYOFYEAR(vDate), 3, 0),
+ IF(vClock IS NULL OR vClock = 99,
+ LPAD(vAgj, 7, 0),
+ CONCAT(LPAD(vAgj, 5, 0), '01')
+ ),
+ '0'
+ );
+ END IF;
+
+ -- Rewrites the kop parameter
+
+ IF vKop IS NULL THEN
+ SELECT defaultKop INTO vKop FROM exchangeConfig;
+ END IF;
+
+ SELECT e.kop INTO vRewriteKop
+ FROM mailSender e
+ JOIN mail m ON m.senderFk = e.id
+ WHERE m.id = vMailFk;
+
+ SET vKop = IFNULL(vRewriteKop, vKop);
+
+ -- Inserts the new transaction
- DECLARE CONTINUE HANDLER FOR duplicateKey
- SET vIsDuplicated = TRUE;
-
- -- Generates the barcode
-
- IF vAgj != 0 AND vAgj IS NOT NULL
- THEN
- SET vBarcode = CONCAT(
- LPAD(vAuction, 2, 0),
- LPAD(IFNULL(vClock, 99), 2, 0),
- LPAD(DAYOFYEAR(vDate), 3, 0),
- IF(vClock IS NULL OR vClock = 99,
- LPAD(vAgj, 7, 0),
- CONCAT(LPAD(vAgj, 5, 0), '01')
- ),
- '0'
- );
- END IF;
-
- -- Rewrites the kop parameter
-
- IF vKop IS NULL THEN
- SELECT defaultKop INTO vKop FROM exchangeConfig;
- END IF;
-
- SELECT e.kop INTO vRewriteKop
- FROM mailSender e
- JOIN mail m ON m.senderFk = e.id
- WHERE m.id = vMailFk;
-
- SET vKop = IFNULL(vRewriteKop, vKop);
-
- -- Inserts the new transaction
-
- SET vIsDuplicated = FALSE;
- INSERT INTO ekt SET
- barcode = IFNULL(vBarcode, barcode)
- ,deliveryNumber = vDeliveryNumber
- ,entryYear = YEAR(vDate)
- ,fec = vDate
- ,hor = vHour
- ,ref = vRef
- ,item = vItem
- ,agj = vAgj
- ,cat = vCat
- ,pac = vPac
- ,sub = vSub
- ,kop = vKop
- ,ptd = vPtd
- ,pro = vPro
- ,ori = vOrigin
- ,ptj = vPtj
- ,qty = vQuantiy
- ,pri = vPrice
- ,klo = vClock
- ,s1 = vS1
- ,s2 = vS2
- ,s3 = vS3
- ,s4 = vS4
- ,s5 = vS5
- ,s6 = vS6
- ,k1 = vK1
- ,k2 = vK2
- ,k3 = vP1
- ,k4 = vP2
- ,auction = vAuction
- ,package = vPackage
- ,putOrderFk = vPutOrderFk;
-
- -- If it exists duplicado updates it
-
- IF NOT vIsDuplicated
- THEN
- SET vEkt = LAST_INSERT_ID();
- CALL ekt_load (vEkt);
-
- ELSEIF vDeliveryNumber != 0
- AND vDeliveryNumber IS NOT NULL
- THEN
- SELECT id INTO vEkt
- FROM ekt
- WHERE deliveryNumber = vDeliveryNumber;
-
- SELECT COUNT(*) = 0 INTO vUpdateExistent
- FROM ekt t
- JOIN `exchange` b ON b.ektFk = t.id
- JOIN exchangeConfig c
- WHERE t.deliveryNumber = vDeliveryNumber
- AND t.entryYear = YEAR(vDate)
- AND b.typeFk != c.presaleFk;
- END IF;
-
- IF vUpdateExistent
- THEN
- UPDATE ekt SET
- barcode = IFNULL(vBarcode, barcode)
- ,fec = vDate
- ,hor = vHour
- ,ref = vRef
- ,item = vItem
- ,agj = vAgj
- ,cat = vCat
- ,pac = vPac
- ,sub = vSub
- ,kop = vKop
- ,ptd = vPtd
- ,pro = vPro
- ,ori = vOrigin
- ,ptj = vPtj
- ,qty = vQuantiy
- ,pri = vPrice
- ,klo = vClock
- ,s1 = vS1
- ,s2 = vS2
- ,s3 = vS3
- ,s4 = vS4
- ,s5 = vS5
- ,s6 = vS6
- ,k1 = vK1
- ,k2 = vK2
- ,k3 = vP1
- ,k4 = vP2
- ,auction = vAuction
- ,package = vPackage
- ,putOrderFk = IFNULL(vPutOrderFk, putOrderFk)
- WHERE id = vEkt;
- END IF;
-
- -- Registers the exchange
-
- INSERT INTO `exchange` SET
- mailFk = vMailFk
- ,typeFk = vType
- ,ektFk = vEkt;
+ SET vIsDuplicated = FALSE;
+ INSERT INTO ekt SET
+ barcode = IFNULL(vBarcode, barcode)
+ ,deliveryNumber = vDeliveryNumber
+ ,entryYear = YEAR(vDate)
+ ,fec = vDate
+ ,hor = vHour
+ ,ref = vRef
+ ,item = vItem
+ ,agj = vAgj
+ ,cat = vCat
+ ,pac = vPac
+ ,sub = vSub
+ ,kop = vKop
+ ,ptd = vPtd
+ ,pro = vPro
+ ,ori = vOrigin
+ ,ptj = vPtj
+ ,qty = vQuantiy
+ ,pri = vPrice
+ ,klo = vClock
+ ,s1 = vS1
+ ,s2 = vS2
+ ,s3 = vS3
+ ,s4 = vS4
+ ,s5 = vS5
+ ,s6 = vS6
+ ,k1 = vK1
+ ,k2 = vK2
+ ,k3 = vP1
+ ,k4 = vP2
+ ,auction = vAuction
+ ,package = vPackage
+ ,putOrderFk = vPutOrderFk;
+
+ -- If it exists duplicado updates it
+
+ IF NOT vIsDuplicated
+ THEN
+ SET vEkt = LAST_INSERT_ID();
+ CALL ekt_load (vEkt);
+
+ ELSEIF vDeliveryNumber != 0
+ AND vDeliveryNumber IS NOT NULL
+ THEN
+ SELECT id INTO vEkt
+ FROM ekt
+ WHERE deliveryNumber = vDeliveryNumber;
+
+ SELECT COUNT(*) = 0 INTO vUpdateExistent
+ FROM ekt t
+ JOIN `exchange` b ON b.ektFk = t.id
+ JOIN exchangeConfig c
+ WHERE t.deliveryNumber = vDeliveryNumber
+ AND t.entryYear = YEAR(vDate)
+ AND b.typeFk != c.presaleFk;
+ END IF;
+
+ IF vUpdateExistent
+ THEN
+ UPDATE ekt SET
+ barcode = IFNULL(vBarcode, barcode)
+ ,fec = vDate
+ ,hor = vHour
+ ,ref = vRef
+ ,item = vItem
+ ,agj = vAgj
+ ,cat = vCat
+ ,pac = vPac
+ ,sub = vSub
+ ,kop = vKop
+ ,ptd = vPtd
+ ,pro = vPro
+ ,ori = vOrigin
+ ,ptj = vPtj
+ ,qty = vQuantiy
+ ,pri = vPrice
+ ,klo = vClock
+ ,s1 = vS1
+ ,s2 = vS2
+ ,s3 = vS3
+ ,s4 = vS4
+ ,s5 = vS5
+ ,s6 = vS6
+ ,k1 = vK1
+ ,k2 = vK2
+ ,k3 = vP1
+ ,k4 = vP2
+ ,auction = vAuction
+ ,package = vPackage
+ ,putOrderFk = IFNULL(vPutOrderFk, putOrderFk)
+ WHERE id = vEkt;
+ END IF;
+
+ -- Registers the exchange
+
+ INSERT INTO `exchange` SET
+ mailFk = vMailFk
+ ,typeFk = vType
+ ,ektFk = vEkt;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -10059,9 +10075,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
-/*!50003 SET character_set_client = utf8mb4 */ ;
-/*!50003 SET character_set_results = utf8mb4 */ ;
-/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
@@ -10076,6 +10092,7 @@ proc: BEGIN
DECLARE vIsAuctionDay BOOLEAN;
DECLARE vMaxNewItems INT DEFAULT 100000;
DECLARE vStartingTime DATETIME;
+ DECLARE vAalsmeerMarketPlaceID VARCHAR(13) DEFAULT '8713783439043';
DECLARE cur1 CURSOR FOR
SELECT id
@@ -10119,10 +10136,11 @@ proc: BEGIN
FROM (
SELECT *
FROM edi.supplyOffer
- ORDER BY NumberOfUnits DESC) t
+ ORDER BY (MarketPlaceID = vAalsmeerMarketPlaceID) DESC, NumberOfUnits DESC) t
JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id
LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode
- GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price ;
+ GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price
+ ;
-- -- select now(),'Antes de crear edi.offer';
DROP TEMPORARY TABLE IF EXISTS edi.offer;
@@ -10374,18 +10392,12 @@ proc: BEGIN
LEFT JOIN edi.putOrder po ON b.deliveryFk = po.deliveryInformationID
LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
SET b.quantity = 0
- WHERE (po.id IS NULL OR di.LatestOrderDateTime < NOW())
- AND sr.ID IS NULL
+ WHERE (di.LatestOrderDateTime < NOW()
+ OR sr.ID IS NULL
+ OR sr.NumberOfUnits = 0)
AND am.name = 'LOGIFLORA'
AND e.isRaid;
- /*
- UPDATE vn.buy b
- JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
- JOIN vn.item i ON i.id = b.itemFk
- LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
- SET b.quantity = 0
- WHERE sr.ID IS NULL;
- */
+
-- Localiza las entradas de cada almacen
UPDATE edi.warehouseFloramondo
SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk);
@@ -10474,6 +10486,429 @@ proc: BEGIN
+END ;;
+DELIMITER ;
+/*!50003 SET sql_mode = @saved_sql_mode */ ;
+/*!50003 SET character_set_client = @saved_cs_client */ ;
+/*!50003 SET character_set_results = @saved_cs_results */ ;
+/*!50003 SET collation_connection = @saved_col_connection */ ;
+/*!50003 DROP PROCEDURE IF EXISTS `floramondo_offerRefresh__` */;
+/*!50003 SET @saved_cs_client = @@character_set_client */ ;
+/*!50003 SET @saved_cs_results = @@character_set_results */ ;
+/*!50003 SET @saved_col_connection = @@collation_connection */ ;
+/*!50003 SET character_set_client = utf8 */ ;
+/*!50003 SET character_set_results = utf8 */ ;
+/*!50003 SET collation_connection = utf8_general_ci */ ;
+/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
+/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
+DELIMITER ;;
+CREATE DEFINER=`root`@`%` PROCEDURE `floramondo_offerRefresh__`()
+proc: BEGIN
+
+ DECLARE vLanded DATETIME;
+ DECLARE done INT DEFAULT FALSE;
+ DECLARE vFreeId INT;
+ DECLARE vSupplyResponseFk INT;
+ DECLARE vLastInserted DATETIME;
+ DECLARE vIsAuctionDay BOOLEAN;
+ DECLARE vMaxNewItems INT DEFAULT 100000;
+ DECLARE vStartingTime DATETIME;
+
+ DECLARE cur1 CURSOR FOR
+ SELECT id
+ FROM edi.item_free;
+
+ DECLARE cur2 CURSOR FOR
+ SELECT srId
+ FROM itemToInsert;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
+ DECLARE EXIT HANDLER FOR SQLSTATE '45000'
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ SET vStartingTime = NOW();
+
+ -- CALL vn.clean_logiflora();
+
+ -- Refresca las fotos de los items existentes, con prioridad baja (0.7 seg)
+ INSERT IGNORE INTO vn.itemImageQueue(itemFk, url,priority)
+ SELECT i.id, sr.PictureReference , 100
+ FROM edi.supplyResponse sr
+ JOIN vn.item i ON i.supplyResponseFk = sr.ID
+ WHERE i.image != edi.imageName(sr.PictureReference)
+ AND sr.NumberOfUnits > 0;
+
+ DELETE itf.*
+ FROM edi.item_free itf
+ JOIN vn.item i ON i.id = itf.id;
+
+ -- -- select now(),'Tras borrar';
+ DROP TEMPORARY TABLE IF EXISTS tmp;
+ CREATE TEMPORARY TABLE tmp (INDEX (`Item_ArticleCode`)) ENGINE = MEMORY
+ SELECT t.*,
+ IFNULL(idt.itemTypeFk, igo.itemTypeFk) itemTypeFk,
+ igo.expenseFk ,
+ igo.intrastatFk ,
+ igo.originFk
+ FROM (
+ SELECT *
+ FROM edi.supplyOffer
+ ORDER BY NumberOfUnits DESC) t
+ JOIN edi.item_groupToOffer igo ON igo.group_code = t.group_id
+ LEFT JOIN edi.item_defaultType idt ON idt.item_id = t.Item_ArticleCode
+ GROUP BY Item_ArticleCode, s1, s2, s3, s4, s5, s6, company_name, Quality, NumberOfItemsPerCask, EmbalageCode, Price ;
+
+ -- -- select now(),'Antes de crear edi.offer';
+ DROP TEMPORARY TABLE IF EXISTS edi.offer;
+ CREATE TEMPORARY TABLE edi.offer (INDEX (`srID`), INDEX (`EmbalageCode`)) ENGINE = MEMORY
+ SELECT so.*, ev1.type_description s1Value, ev2.type_description s2Value, ev3.type_description s3Value,
+ ev4.type_description s4Value, ev5.type_description s5Value, ev6.type_description s6Value,
+ eif1.feature ef1, eif2.feature ef2, eif3.feature ef3, eif4.feature ef4, eif5.feature ef5, eif6.feature ef6
+ FROM tmp so
+ LEFT JOIN edi.item_feature eif1 ON eif1.item_id = so.Item_ArticleCode
+ AND eif1.presentation_order = 1 AND eif1.expiry_date IS NULL
+ LEFT JOIN edi.item_feature eif2 ON eif2.item_id = so.Item_ArticleCode
+ AND eif2.presentation_order = 2 AND eif2.expiry_date IS NULL
+ LEFT JOIN edi.item_feature eif3 ON eif3.item_id = so.Item_ArticleCode
+ AND eif3.presentation_order = 3 AND eif3.expiry_date IS NULL
+ LEFT JOIN edi.item_feature eif4 ON eif4.item_id = so.Item_ArticleCode
+ AND eif4.presentation_order = 4 AND eif4.expiry_date IS NULL
+ LEFT JOIN edi.item_feature eif5 ON eif5.item_id = so.Item_ArticleCode
+ AND eif5.presentation_order = 5 AND eif5.expiry_date IS NULL
+ LEFT JOIN edi.item_feature eif6 ON eif6.item_id = so.Item_ArticleCode
+ AND eif6.presentation_order = 6 AND eif6.expiry_date IS NULL
+ LEFT JOIN edi.`value` ev1 ON ev1.type_id = eif1.feature AND so.s1 = ev1.type_value
+ LEFT JOIN edi.`value` ev2 ON ev2.type_id = eif2.feature AND so.s2 = ev2.type_value
+ LEFT JOIN edi.`value` ev3 ON ev3.type_id = eif3.feature AND so.s3 = ev3.type_value
+ LEFT JOIN edi.`value` ev4 ON ev4.type_id = eif4.feature AND so.s4 = ev4.type_value
+ LEFT JOIN edi.`value` ev5 ON ev5.type_id = eif5.feature AND so.s5 = ev5.type_value
+ LEFT JOIN edi.`value` ev6 ON ev6.type_id = eif6.feature AND so.s6 = ev6.type_value
+ ORDER BY Price;
+
+ DROP TEMPORARY TABLE tmp;
+
+
+ START TRANSACTION;
+
+ -- Actualizamos el campo supplyResponseFk para aquellos articulos que ya estan creados y reutilizamos
+ UPDATE IGNORE edi.offer o
+ LEFT JOIN vn.item iExist ON iExist.supplyResponseFk = o.srID
+ JOIN vn.item i
+ ON i.name = o.product_name
+ AND i.subname <=> o.company_name
+ AND i.value5 <=> o.s1Value
+ AND i.value6 <=> o.s2Value
+ AND i.value7 <=> o.s3Value
+ AND i.value8 <=> o.s4Value
+ AND i.value9 <=> o.s5Value
+ AND i.value10 <=> o.s6Value
+ AND i.NumberOfItemsPerCask <=> o.NumberOfItemsPerCask
+ AND i.EmbalageCode <=> o.EmbalageCode
+ AND i.quality <=> o.Quality
+ LEFT JOIN deliveryInformation di ON di.supplyResponseID = i.supplyResponseFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ SET i.supplyResponseFk = o.srID
+ WHERE iExist.id IS NULL
+ AND (di.LatestOrderDateTime < NOW() OR di.ID IS NULL)
+ AND it.isInventory
+ ;
+ -- select now(),'Antes de crear ITO';
+ DROP TEMPORARY TABLE IF EXISTS itemToInsert;
+ CREATE TEMPORARY TABLE itemToInsert ENGINE = MEMORY
+ SELECT o.*, CAST(NULL AS DECIMAL(6,0)) as itemFk
+ FROM edi.offer o
+ LEFT JOIN vn.item i ON i.supplyResponseFk = o.srId
+ WHERE i.id IS NULL
+ LIMIT vMaxNewItems;
+
+ -- Reciclado de nº de item
+ OPEN cur1;
+ OPEN cur2;
+
+ read_loop: LOOP
+
+ FETCH cur2 INTO vSupplyResponseFk;
+ FETCH cur1 INTO vFreeId;
+
+ IF done THEN
+ LEAVE read_loop;
+ END IF;
+
+ UPDATE itemToInsert
+ SET itemFk = vFreeId
+ WHERE srId = vSupplyResponseFk;
+
+ END LOOP;
+
+ CLOSE cur1;
+ CLOSE cur2;
+
+ -- Insertamos todos los items en Articles de la oferta
+ INSERT INTO vn.item( id,
+ `name`,
+ longName,
+ subName,
+ expenceFk,
+ typeFk,
+ intrastatFk,
+ originFk,
+ supplyResponseFk,
+ numberOfItemsPerCask,
+ embalageCode,
+ quality,
+ isFloramondo)
+ SELECT itemFk,
+ product_name,
+ product_name,
+ company_name,
+ expenseFk,
+ itemTypeFk,
+ intrastatFk,
+ originFk,
+ `srId`,
+ NumberOfItemsPerCask,
+ EmbalageCode,
+ Quality,
+ TRUE
+ FROM itemToInsert;
+
+ INSERT IGNORE INTO vn.itemImageQueue(itemFk, url)
+ SELECT i.id, PictureReference
+ FROM itemToInsert ii
+ JOIN vn.item i ON i.supplyResponseFk = ii.srId
+ WHERE PictureReference IS NOT NULL;
+
+ INSERT INTO edi.log(tableName, fieldName,fieldValue)
+ SELECT 'itemImageQueue','NumImagenesPtes', COUNT(*)
+ FROM vn.itemImageQueue
+ WHERE attempts = 0;
+
+ -- Inserta si se añadiesen tags nuevos
+ INSERT IGNORE INTO vn.tag (name, ediTypeFk)
+ SELECT description, type_id FROM edi.type;
+
+ -- Inserta los tags sólo en los articulos nuevos
+
+ -- desabilita el trigger para recalcular los tags al final
+ SET @isTriggerDisabled = TRUE;
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , ii.product_name, 1
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.`name` = 'Producto'
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , ii.Quality, 3
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.`name` = 'Calidad'
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , ii.company_name, 4
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.`name` = 'Productor'
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`;
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s1Value, 5
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef1
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s1Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s2Value, 6
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef2
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s2Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s3Value, 7
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef3
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s3Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s4Value, 8
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef4
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s4Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s5Value, 9
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef5
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s5Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id , s6Value, 10
+ FROM itemToInsert ii
+ JOIN vn.tag t ON t.ediTypeFk = ii.ef6
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ WHERE s6Value != '';
+
+ INSERT INTO vn.itemTag(itemFk, tagFk, value, priority)
+ SELECT i.id, t.id, ink.name, 11
+ FROM itemToInsert ii
+ JOIN vn.item i ON i.supplyResponseFk = ii.`srId`
+ JOIN vn.tag t ON t.`name` = 'Color'
+ JOIN edi.feature f ON f.item_id = ii.Item_ArticleCode
+ JOIN edi.`type` tp ON tp.type_id = f.feature_type_id AND tp.`description` = 'Hoofdkleur 1'
+ JOIN vn.ink ON ink.dutchCode = f.feature_value;
+
+ UPDATE vn.item i
+ JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`
+ JOIN vn.packaging p ON p.id LIKE ii.EmbalageCode AND hasCompressionVariations
+ JOIN vn.itemTag diameter ON diameter.itemFk = i.id
+ JOIN vn.tag tDiameter ON tDiameter.overwrite = 'diameter' AND tDiameter.id = diameter.tagFk
+ JOIN vn.itemTag size ON size.itemFk = i.id
+ JOIN vn.tag tSize ON tSize.overwrite = 'size' AND tSize.id = size.tagFk
+ SET i.`compression` =
+ (PI() * POW(diameter.`value`/ 2, 2) * size.`value`)
+ /
+ ((p.width * p.depth * p.height) / ii.NumberOfItemsPerCask);
+
+ DROP TABLE IF EXISTS tmp.item;
+ CREATE TABLE tmp.item
+ (PRIMARY KEY (id))
+ SELECT i.id FROM vn.item i
+ JOIN itemToInsert ii ON i.supplyResponseFk = ii.`srId`;
+
+ CALL vn.item_refreshTags();
+
+ SET @isTriggerDisabled = FALSE;
+
+ SELECT MIN(LatestDeliveryDateTime) INTO vLanded
+ FROM edi.supplyResponse sr
+ JOIN edi.deliveryInformation di ON di.supplyResponseID = sr.ID
+ JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
+ JOIN vn.floramondoConfig fc
+ WHERE mp.isLatestOrderDateTimeRelevant
+ AND di.LatestOrderDateTime > IF(fc.MaxLatestOrderHour > HOUR(NOW()), CURDATE(), TIMESTAMPADD(DAY,1,CURDATE()));
+
+ UPDATE vn.floramondoConfig
+ SET nextLanded = vLanded
+ WHERE vLanded IS NOT NULL;
+
+
+ -- Elimina la oferta obsoleta
+ UPDATE vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.agencyMode am ON am.id = tr.agencyFk
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN edi.supplyResponse sr ON i.supplyResponseFk = sr.ID
+ LEFT JOIN edi.putOrder po ON b.deliveryFk = po.deliveryInformationID
+ LEFT JOIN edi.deliveryInformation di ON di.ID = b.deliveryFk
+ SET b.quantity = 0
+ WHERE (po.id IS NULL OR di.LatestOrderDateTime < NOW())
+ AND sr.ID IS NULL
+ AND am.name = 'LOGIFLORA'
+ AND e.isRaid;
+
+ UPDATE vn.buy b
+ JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
+ JOIN vn.item i ON i.id = b.itemFk
+ LEFT JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk
+ SET b.quantity = 0
+ WHERE sr.ID IS NULL;
+
+ -- Localiza las entradas de cada almacen
+ UPDATE edi.warehouseFloramondo
+ SET entryFk = vn.floramondo_getEntry(TIMESTAMPADD(DAY,travellingDays,vLanded), warehouseFk);
+
+ IF vLanded IS NOT NULL THEN
+ -- actualiza la oferta existente
+ UPDATE vn.buy b
+ JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN edi.offer o ON i.supplyResponseFk = o.`srId`
+ SET b.quantity = o.NumberOfUnits * o.NumberOfItemsPerCask,
+ b.buyingValue = o.price
+ WHERE (b.quantity <> o.NumberOfUnits * o.NumberOfItemsPerCask OR b.buyingValue <> o.price);
+
+ -- Se eliminan las ofertas ya incluidas en las entradas
+ DELETE o
+ FROM edi.offer o
+ JOIN vn.item i ON i.supplyResponseFk = o.srId
+ JOIN vn.buy b ON i.id = b.itemFk
+ JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk;
+
+ -- Se inserta el resto
+ SET vLastInserted := NOW();
+
+ -- Inserta la oferta
+ INSERT INTO vn.buy(entryFk,
+ itemFk,
+ quantity,
+ buyingValue,
+ stickers,
+ packing,
+ `grouping`,
+ groupingMode,
+ packageFk,
+ deliveryFk)
+
+ SELECT wf.entryFk,
+ i.id,
+ o.NumberOfUnits * o.NumberOfItemsPerCask as quantity,
+ o.Price,
+ o.NumberOfUnits as etiquetas,
+ o.NumberOfItemsPerCask as packing,
+ GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask as `grouping`,
+ 2, -- Obliga al Packing
+ o.embalageCode,
+ o.diId
+ FROM edi.offer o
+ JOIN vn.item i ON i.supplyResponseFk = o.srId
+ JOIN vn.itemType it ON it.id = i.typeFk
+ JOIN edi.warehouseFloramondo wf ON wf.isFV = it.isFV OR wf.isFV IS NULL
+ JOIN vn.packaging p ON p.id LIKE o.embalageCode; -- llevar esta linea i mirar de crear els packages a temps real
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
+
+ CREATE TEMPORARY TABLE tmp.buyRecalc
+ SELECT b.id
+ FROM vn.buy b
+ JOIN edi.warehouseFloramondo wf ON wf.entryFk = b.entryFk
+ WHERE b.created >= vLastInserted;
+
+ CALL vn.buy_recalcPrices();
+
+ END IF;
+
+ DROP TEMPORARY TABLE
+ edi.offer,
+ itemToInsert;
+
+ DROP TABLE tmp.item;
+
+ COMMIT;
+
+ -- Esto habria que pasarlo a procesos programados o trabajar con tags y dejar las familias
+ UPDATE vn.item i
+ SET typeFk = 121
+ WHERE i.longName LIKE 'Rosa Garden %'
+ AND typeFk = 17;
+
+ UPDATE vn.item i
+ SET typeFk = 156
+ WHERE i.longName LIKE 'Rosa ec %'
+ AND typeFk = 17;
+
+ INSERT INTO edi.log(tableName, fieldName,fieldValue)
+ VALUES('floramondo_offerRefresh','Tiempo de proceso',TIMEDIFF(NOW(),vStartingTime));
+
+
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -12593,30 +13028,30 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `item_listAllocation`(IN `vWh` TINYINT, IN `vDate` DATE, IN `vType` INT, IN `vPrefix` VARCHAR(255), IN `vUseIds` BOOLEAN)
-BEGIN
-/**
- * Lists visible items and it's box sizes of the specified
- * type at specified date.
- *
- * @param vWh The warehouse id
- * @param vDate The visible date
- * @param vType The type id
- * @param vPrefix The article prefix to filter or %NULL for all
- * @param vUseIds Whether to order the result by item id
- * @select List of visible items with it's box sizes
- */
- CALL item_getVisible(vWh, vDate, vType, vPrefix);
-
- IF vUseIds
- THEN
- SELECT * FROM tmp.itemVisible
- ORDER BY Id_Article;
- ELSE
- SELECT * FROM tmp.itemVisible
- ORDER BY Article, packing;
- END IF;
-
- DROP TEMPORARY TABLE tmp.itemVisible;
+BEGIN
+/**
+ * Lists visible items and it's box sizes of the specified
+ * type at specified date.
+ *
+ * @param vWh The warehouse id
+ * @param vDate The visible date
+ * @param vType The type id
+ * @param vPrefix The article prefix to filter or %NULL for all
+ * @param vUseIds Whether to order the result by item id
+ * @select List of visible items with it's box sizes
+ */
+ CALL item_getVisible(vWh, vDate, vType, vPrefix);
+
+ IF vUseIds
+ THEN
+ SELECT * FROM tmp.itemVisible
+ ORDER BY Id_Article;
+ ELSE
+ SELECT * FROM tmp.itemVisible
+ ORDER BY Article, packing;
+ END IF;
+
+ DROP TEMPORARY TABLE tmp.itemVisible;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -12763,82 +13198,82 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`%` PROCEDURE `myBasket_configure`(
- vDelivery DATE,
- vDeliveryMethod VARCHAR(45),
- vAgency INT,
+CREATE DEFINER=`root`@`%` PROCEDURE `myBasket_configure`(
+ vDelivery DATE,
+ vDeliveryMethod VARCHAR(45),
+ vAgency INT,
vAddress INT)
-BEGIN
-/**
- * Configura la cesta de la compra utilizando los parámetros
- * pasados. Si los parámetros no son válidos devuelve un error.
- *
- * @param vDelivery Fecha de recogida
- * @param vAgency Id de la agencia
- * @param vAddress Id de dirección de envío, @NULL si es recogida
- */
- DECLARE vSelf INT;
- DECLARE vCompany INT;
- DECLARE vDeliveryMethodId INT;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- SELECT id INTO vDeliveryMethodId
- FROM vn.deliveryMethod
- WHERE code = vDeliveryMethod;
-
- IF vDeliveryMethod = 'PICKUP' AND vAddress IS NULL
- THEN
- SELECT defaultAddressFk INTO vAddress
- FROM myClient;
- END IF;
-
- SET vSelf = myBasket_getId();
-
- IF vSelf IS NULL
- THEN
-
- SELECT defaultCompanyFk INTO vCompany
- FROM orderConfig;
-
- INSERT INTO `order`
- SET
- customer_id = account.userGetId(),
- date_send = vDelivery,
- delivery_method_id = vDeliveryMethodId,
- agency_id = vAgency,
- address_id = vAddress,
- source_app = 'WEB',
- company_id = vCompany;
-
- SET vSelf = LAST_INSERT_ID();
-
- INSERT INTO basketOrder SET
- clientFk = account.userGetId(),
- orderFk = vSelf;
- ELSE
- UPDATE `order`
- SET
- date_send = vDelivery,
- delivery_method_id = vDeliveryMethodId,
- agency_id = vAgency,
- address_id = vAddress
- WHERE
- id = vSelf;
-
- CALL order_update(vSelf);
- END IF;
-
- CALL order_checkConfig(vSelf);
-
- COMMIT;
+BEGIN
+/**
+ * Configura la cesta de la compra utilizando los parámetros
+ * pasados. Si los parámetros no son válidos devuelve un error.
+ *
+ * @param vDelivery Fecha de recogida
+ * @param vAgency Id de la agencia
+ * @param vAddress Id de dirección de envío, @NULL si es recogida
+ */
+ DECLARE vSelf INT;
+ DECLARE vCompany INT;
+ DECLARE vDeliveryMethodId INT;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
+ DECLARE EXIT HANDLER FOR SQLSTATE '45000'
+ BEGIN
+ ROLLBACK;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT id INTO vDeliveryMethodId
+ FROM vn.deliveryMethod
+ WHERE code = vDeliveryMethod;
+
+ IF vDeliveryMethod = 'PICKUP' AND vAddress IS NULL
+ THEN
+ SELECT defaultAddressFk INTO vAddress
+ FROM myClient;
+ END IF;
+
+ SET vSelf = myBasket_getId();
+
+ IF vSelf IS NULL
+ THEN
+
+ SELECT defaultCompanyFk INTO vCompany
+ FROM orderConfig;
+
+ INSERT INTO `order`
+ SET
+ customer_id = account.userGetId(),
+ date_send = vDelivery,
+ delivery_method_id = vDeliveryMethodId,
+ agency_id = vAgency,
+ address_id = vAddress,
+ source_app = 'WEB',
+ company_id = vCompany;
+
+ SET vSelf = LAST_INSERT_ID();
+
+ INSERT INTO basketOrder SET
+ clientFk = account.userGetId(),
+ orderFk = vSelf;
+ ELSE
+ UPDATE `order`
+ SET
+ date_send = vDelivery,
+ delivery_method_id = vDeliveryMethodId,
+ agency_id = vAgency,
+ address_id = vAddress
+ WHERE
+ id = vSelf;
+
+ CALL order_update(vSelf);
+ END IF;
+
+ CALL order_checkConfig(vSelf);
+
+ COMMIT;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -13063,62 +13498,62 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`%` PROCEDURE `myOrder_newWithAddress`(
- OUT vSelf INT,
- vLandingDate DATE,
+CREATE DEFINER=`root`@`%` PROCEDURE `myOrder_newWithAddress`(
+ OUT vSelf INT,
+ vLandingDate DATE,
vAddressFk INT)
-BEGIN
-/**
- * Crea una nueva orden para el usuario actual especificando
- * una fecha de entrega.
- *
- * @param vSelf Id de la nueva orden
- * @param vLandingDate Fecha de entrega
- */
- DECLARE vCompany INT;
- DECLARE vDeliveryMethodId INT;
- DECLARE vAgencyMode INT;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- SET vSelf = NULL;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- SELECT a.agencyModeFk, a.id
- INTO vAgencyMode, vAddressFk
- FROM vn.address a
- WHERE a.id = vAddressFk;
-
- SELECT deliveryMethodFk INTO vDeliveryMethodId
- FROM vn.agencyMode am
- WHERE am.id = vAgencyMode;
-
- IF vCompany IS NULL
- THEN
- SELECT defaultCompanyFk INTO vCompany
- FROM orderConfig;
- END IF;
-
- INSERT INTO `order`
- SET
- customer_id = account.userGetId(),
- date_send = vLandingDate,
- delivery_method_id = vDeliveryMethodId,
- agency_id = vAgencyMode,
- address_id = vAddressFk,
- source_app = 'WEB',
- company_id = vCompany;
-
- SET vSelf = LAST_INSERT_ID();
-
- CALL order_checkConfig(vSelf);
-
- COMMIT;
+BEGIN
+/**
+ * Crea una nueva orden para el usuario actual especificando
+ * una fecha de entrega.
+ *
+ * @param vSelf Id de la nueva orden
+ * @param vLandingDate Fecha de entrega
+ */
+ DECLARE vCompany INT;
+ DECLARE vDeliveryMethodId INT;
+ DECLARE vAgencyMode INT;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
+ DECLARE EXIT HANDLER FOR SQLSTATE '45000'
+ BEGIN
+ ROLLBACK;
+ SET vSelf = NULL;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT a.agencyModeFk, a.id
+ INTO vAgencyMode, vAddressFk
+ FROM vn.address a
+ WHERE a.id = vAddressFk;
+
+ SELECT deliveryMethodFk INTO vDeliveryMethodId
+ FROM vn.agencyMode am
+ WHERE am.id = vAgencyMode;
+
+ IF vCompany IS NULL
+ THEN
+ SELECT defaultCompanyFk INTO vCompany
+ FROM orderConfig;
+ END IF;
+
+ INSERT INTO `order`
+ SET
+ customer_id = account.userGetId(),
+ date_send = vLandingDate,
+ delivery_method_id = vDeliveryMethodId,
+ agency_id = vAgencyMode,
+ address_id = vAddressFk,
+ source_app = 'WEB',
+ company_id = vCompany;
+
+ SET vSelf = LAST_INSERT_ID();
+
+ CALL order_checkConfig(vSelf);
+
+ COMMIT;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -13135,62 +13570,62 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`%` PROCEDURE `myOrder_newWithDate`(
- OUT vSelf INT,
+CREATE DEFINER=`root`@`%` PROCEDURE `myOrder_newWithDate`(
+ OUT vSelf INT,
vLandingDate DATE)
-BEGIN
-/**
- * Crea una nueva orden para el usuario actual especificando
- * una fecha de entrega.
- *
- * @param vSelf Id de la nueva orden
- * @param vLandingDate Fecha de entrega
- */
- DECLARE vCompany INT;
- DECLARE vDeliveryMethodId INT;
- DECLARE vAgencyMode INT;
- DECLARE vAddress INT;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
- DECLARE EXIT HANDLER FOR SQLSTATE '45000'
- BEGIN
- ROLLBACK;
- SET vSelf = NULL;
- RESIGNAL;
- END;
-
- START TRANSACTION;
-
- SELECT a.agencyModeFk, a.id
- INTO vAgencyMode, vAddress
- FROM myClient c
- JOIN vn.address a ON a.id = c.defaultAddressFk;
-
- SELECT deliveryMethodFk INTO vDeliveryMethodId
- FROM vn.agencyMode am
- WHERE am.id = vAgencyMode;
-
- IF vCompany IS NULL
- THEN
- SELECT defaultCompanyFk INTO vCompany
- FROM orderConfig;
- END IF;
-
- INSERT INTO `order`
- SET
- customer_id = account.userGetId(),
- date_send = vLandingDate,
- delivery_method_id = vDeliveryMethodId,
- agency_id = vAgencyMode,
- address_id = vAddress,
- source_app = 'WEB',
- company_id = vCompany;
-
- SET vSelf = LAST_INSERT_ID();
-
- CALL order_checkConfig(vSelf);
-
- COMMIT;
+BEGIN
+/**
+ * Crea una nueva orden para el usuario actual especificando
+ * una fecha de entrega.
+ *
+ * @param vSelf Id de la nueva orden
+ * @param vLandingDate Fecha de entrega
+ */
+ DECLARE vCompany INT;
+ DECLARE vDeliveryMethodId INT;
+ DECLARE vAgencyMode INT;
+ DECLARE vAddress INT;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vSelf = NULL;
+ DECLARE EXIT HANDLER FOR SQLSTATE '45000'
+ BEGIN
+ ROLLBACK;
+ SET vSelf = NULL;
+ RESIGNAL;
+ END;
+
+ START TRANSACTION;
+
+ SELECT a.agencyModeFk, a.id
+ INTO vAgencyMode, vAddress
+ FROM myClient c
+ JOIN vn.address a ON a.id = c.defaultAddressFk;
+
+ SELECT deliveryMethodFk INTO vDeliveryMethodId
+ FROM vn.agencyMode am
+ WHERE am.id = vAgencyMode;
+
+ IF vCompany IS NULL
+ THEN
+ SELECT defaultCompanyFk INTO vCompany
+ FROM orderConfig;
+ END IF;
+
+ INSERT INTO `order`
+ SET
+ customer_id = account.userGetId(),
+ date_send = vLandingDate,
+ delivery_method_id = vDeliveryMethodId,
+ agency_id = vAgencyMode,
+ address_id = vAddress,
+ source_app = 'WEB',
+ company_id = vCompany;
+
+ SET vSelf = LAST_INSERT_ID();
+
+ CALL order_checkConfig(vSelf);
+
+ COMMIT;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -20603,7 +21038,7 @@ BEGIN
mc.ImporteRetencion,
mc.SiglaNacion,
mc.EjercicioFactura,
- mc.FechaOperacion,
+ x.FECHA,
mc.Exclusion347,
mc.MantenerAsiento,
mc.Metalico347,
@@ -22388,8 +22823,8 @@ DELIMITER ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `log_add_beta__`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255))
-proc: BEGIN
- -- XXX: Disabled while testing
+proc: BEGIN
+ -- XXX: Disabled while testing
DECLARE vLanded DATE;
DECLARE vWarehouseFk INT;
DECLARE vBuyerFk INT;
@@ -22397,20 +22832,20 @@ proc: BEGIN
DECLARE vItemFk INT;
DECLARE vItemName VARCHAR(50);
- -- LEAVE proc;
+ -- LEAVE proc;
- IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN
- INSERT IGNORE INTO `log` SET
- tableName = vTableName,
- tableId = vOldId,
- operation = 'delete';
- END IF;
-
- IF vNewId IS NOT NULL THEN
- INSERT IGNORE INTO `log` SET
- tableName = vTableName,
- tableId = vNewId,
- operation = 'insert';
+ IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN
+ INSERT IGNORE INTO `log` SET
+ tableName = vTableName,
+ tableId = vOldId,
+ operation = 'delete';
+ END IF;
+
+ IF vNewId IS NOT NULL THEN
+ INSERT IGNORE INTO `log` SET
+ tableName = vTableName,
+ tableId = vNewId,
+ operation = 'insert';
END IF;
IF vTableName = 'buy' THEN
@@ -22440,7 +22875,7 @@ proc: BEGIN
END IF;
END IF;
-
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -22708,29 +23143,29 @@ CREATE DEFINER=`root`@`%` PROCEDURE `log_refreshSale`(
BEGIN
DROP TEMPORARY TABLE IF EXISTS tValues;
CREATE TEMPORARY TABLE tValues
- ENGINE = MEMORY
- SELECT
- m.id saleFk,
- m.ticketFk,
- m.itemFk,
- t.warehouseFk,
- t.shipped,
+ ENGINE = MEMORY
+ SELECT
+ m.id saleFk,
+ m.ticketFk,
+ m.itemFk,
+ t.warehouseFk,
+ t.shipped,
ABS(m.quantity) quantity,
m.created,
TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
m.quantity < 0 isIn,
- m.isPicked OR s.alertLevel > 1 isPicked
- FROM vn.sale m
- JOIN vn.ticket t ON t.id = m.ticketFk
+ m.isPicked OR s.alertLevel > 1 isPicked
+ FROM vn.sale m
+ JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = m.itemFk
- JOIN vn.itemType tp ON tp.id = i.typeFk
+ JOIN vn.itemType tp ON tp.id = i.typeFk
WHERE (
- vTableId IS NULL
- OR (vTableName = 'ticket' AND t.id = vTableId)
- OR (vTableName = 'sale' AND m.id = vTableId)
- )
- AND t.shipped >= vn.getInventoryDate()
+ vTableId IS NULL
+ OR (vTableName = 'ticket' AND t.id = vTableId)
+ OR (vTableName = 'sale' AND m.id = vTableId)
+ )
+ AND t.shipped >= vn.getInventoryDate()
AND m.quantity != 0;
REPLACE INTO inbound (
@@ -22763,7 +23198,7 @@ BEGIN
FROM tValues
WHERE !isIn;
- DROP TEMPORARY TABLE tValues;
+ DROP TEMPORARY TABLE tValues;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -24440,7 +24875,8 @@ SET character_set_client = utf8;
`account` tinyint NOT NULL,
`accountingTypeFk` tinyint NOT NULL,
`entityFk` tinyint NOT NULL,
- `isActive` tinyint NOT NULL
+ `isActive` tinyint NOT NULL,
+ `currencyFk` tinyint NOT NULL
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
@@ -25206,8 +25642,8 @@ DROP TABLE IF EXISTS `botanicExport`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `botanicExport` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `vnGenusFk` mediumint(8) unsigned NOT NULL,
- `vnSpecieFk` mediumint(8) unsigned DEFAULT NULL,
+ `ediGenusFk` mediumint(8) unsigned NOT NULL,
+ `ediSpecieFk` mediumint(8) unsigned DEFAULT NULL,
`countryFk` mediumint(8) unsigned DEFAULT NULL,
`restriction` enum('Sin restriccion','Importacion Prohibida','pasaporte fitosanitario','pasaporte individual','declaracion origen') CHARACTER SET utf8 NOT NULL,
`description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -25215,8 +25651,8 @@ CREATE TABLE `botanicExport` (
`code` enum('importProhibited','phytosanitaryPassport','individualPassport') COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Id_Paises` (`countryFk`),
- KEY `botanicExport_ibfk_2_idx` (`vnGenusFk`),
- KEY `botanicExport_ibfk_3_idx` (`vnSpecieFk`),
+ KEY `botanicExport_ibfk_2_idx` (`ediGenusFk`),
+ KEY `botanicExport_ibfk_3_idx` (`ediSpecieFk`),
CONSTRAINT `botanicExport_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`)
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Especifica los generos y especies prohibidos en paises';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -25231,7 +25667,7 @@ CREATE TABLE `botanicExport` (
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`botanicExport_beforeInsert` BEFORE INSERT ON `botanicExport` FOR EACH ROW
BEGIN
- IF (SELECT botanicExport_isUpdatable (NEW.vnGenusFk, NEW.vnSpecieFk, NEW.countryFk, NEW.restriction) ) > 0 THEN
+ IF (SELECT botanicExport_isUpdatable (NEW.ediGenusFk, NEW.ediSpecieFk, NEW.countryFk, NEW.restriction) ) > 0 THEN
CALL util.throw ('Datos duplicados');
END IF;
END */;;
@@ -26711,7 +27147,7 @@ CREATE TABLE `cmr_expeditionPallet` (
KEY `cmr_expeditionPallet_fk2_idx` (`expeditionPalletFk`),
CONSTRAINT `cmr_expeditionPallet_fk1` FOREIGN KEY (`cmrFk`) REFERENCES `cmr` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `cmr_expeditionPallet_fk2` FOREIGN KEY (`expeditionPalletFk`) REFERENCES `expeditionPallet` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
-) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='relaciona los cmr con los pallets de expediciones';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='relaciona los cmr con los pallets de expediciones';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -28247,30 +28683,37 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
--- Temporary table structure for view `vnGenus`
+-- Temporary table structure for view `ediGenus`
--
-DROP TABLE IF EXISTS `vnGenus`;
-/*!50001 DROP VIEW IF EXISTS `vnGenus`*/;
+DROP TABLE IF EXISTS `ediGenus`;
+/*!50001 DROP VIEW IF EXISTS `ediGenus`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
-/*!50001 CREATE TABLE `vnGenus` (
+/*!50001 CREATE TABLE `ediGenus` (
`id` tinyint NOT NULL,
- `name` tinyint NOT NULL
+ `latinGenusName` tinyint NOT NULL,
+ `entried` tinyint NOT NULL,
+ `dued` tinyint NOT NULL,
+ `modified` tinyint NOT NULL
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
--
--- Temporary table structure for view `vnSpecie`
+-- Temporary table structure for view `ediSpecie`
--
-DROP TABLE IF EXISTS `vnSpecie`;
-/*!50001 DROP VIEW IF EXISTS `vnSpecie`*/;
+DROP TABLE IF EXISTS `ediSpecie`;
+/*!50001 DROP VIEW IF EXISTS `ediSpecie`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
-/*!50001 CREATE TABLE `vnSpecie` (
+/*!50001 CREATE TABLE `ediSpecie` (
`id` tinyint NOT NULL,
- `name` tinyint NOT NULL
+ `genusFk` tinyint NOT NULL,
+ `latinSpeciesName` tinyint NOT NULL,
+ `entried` tinyint NOT NULL,
+ `dued` tinyint NOT NULL,
+ `modified` tinyint NOT NULL
) ENGINE=MyISAM */;
SET character_set_client = @saved_cs_client;
@@ -28642,6 +29085,26 @@ CREATE TABLE `entryLog` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `entryObservation`
+--
+
+DROP TABLE IF EXISTS `entryObservation`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `entryObservation` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `entryFk` int(11) NOT NULL,
+ `observationTypeFk` tinyint(3) unsigned DEFAULT NULL,
+ `description` text COLLATE utf8_unicode_ci DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `entryFk_observationTypeFk_UNIQUE` (`entryFk`,`observationTypeFk`),
+ KEY `observationType_id_observationTypeFk` (`observationTypeFk`),
+ CONSTRAINT `entry_id_entryFk` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`),
+ CONSTRAINT `observationType_id_observationTypeFk` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `entryShelving__`
--
@@ -30416,10 +30879,10 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `vn`.`invoiceOut` FOR EACH ROW
-BEGIN
-CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount);
-CALL clientRisk_update (NEW.clientFk, NEW.companyFk, NEW.amount);
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`invoiceOut_beforeUpdate` BEFORE UPDATE ON `vn`.`invoiceOut` FOR EACH ROW
+BEGIN
+CALL clientRisk_update (OLD.clientFk, OLD.companyFk, -OLD.amount);
+CALL clientRisk_update (NEW.clientFk, NEW.companyFk, NEW.amount);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -30749,14 +31212,13 @@ DROP TABLE IF EXISTS `itemBotanical`;
CREATE TABLE `itemBotanical` (
`itemFk` int(11) NOT NULL,
`botanical` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
- `genusFk` int(11) DEFAULT NULL,
+ `genusFk` int(11) NOT NULL,
`specieFk` int(11) DEFAULT NULL,
PRIMARY KEY (`itemFk`),
KEY `genusFgn_idx` (`genusFk`),
KEY `specieFgn_idx` (`specieFk`),
CONSTRAINT `itemBotanicalItemFkFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT `itemBotanical_fk2` FOREIGN KEY (`genusFk`) REFERENCES `genus` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT `itemBotanical_FK` FOREIGN KEY (`specieFk`) REFERENCES `specie` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye a antiguo NomBotanic de Articles';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -30768,15 +31230,15 @@ CREATE TABLE `itemBotanical` (
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW
-BEGIN
-/**
- * Hay una versión en salix que machacará toda esta función/procedimiento avisa
- * a jgallego de los cambios que quieres hacer.
- */
- IF (NEW.botanical >= '') THEN
- CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie');
- END IF;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeInsert` BEFORE INSERT ON `itemBotanical` FOR EACH ROW
+BEGIN
+/**
+ * Hay una versión en salix que machacará toda esta función/procedimiento avisa
+ * a jgallego de los cambios que quieres hacer.
+ */
+ IF (NEW.botanical >= '') THEN
+ CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie');
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -30792,15 +31254,15 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW
-BEGIN
-/**
- * Hay una versión en salix que machacará toda esta función/procedimiento avisa
- * a jgallego de los cambios que quieres hacer.
-
- IF (NEW.botanical >= '') THEN
- CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie');
- END IF; */
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemBotanical_beforeUpdate` BEFORE UPDATE ON `itemBotanical` FOR EACH ROW
+BEGIN
+/**
+ * Hay una versión en salix que machacará toda esta función/procedimiento avisa
+ * a jgallego de los cambios que quieres hacer.
+
+ IF (NEW.botanical >= '') THEN
+ CALL util.throw('no se puede modificar el nombre botanico, use los campos genero y especie');
+ END IF; */
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -33967,11 +34429,20 @@ CREATE TABLE `receipt` (
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER vn.receipt_beforeInsert
-BEFORE INSERT
-ON receipt FOR EACH ROW
-BEGIN
-
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER vn.receipt_beforeInsert
+BEFORE INSERT
+ON receipt FOR EACH ROW
+BEGIN
+ DECLARE vIsAutoConciliated BOOLEAN;
+
+ IF NEW.isConciliate = FALSE THEN
+ SELECT isAutoConciliated INTO vIsAutoConciliated
+ FROM accounting a
+ JOIN accountingType at2 ON at2.id = a.accountingTypeFk
+ WHERE a.id = NEW.bankFk;
+
+ SET NEW.isConciliate = vIsAutoConciliated;
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -34022,14 +34493,14 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` AFTER UPDATE ON `receipt` FOR EACH ROW
-BEGIN
- IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN
- INSERT INTO vn.mail(`sender`, subject, `body`)
- SELECT 'finanzas@verdnatura.es',
- CONCAT(' Cambios de recibos del cliente: ', NEW.clientFk),
- CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed);
- END IF;
+/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`receipt_afterUpdate` AFTER UPDATE ON `receipt` FOR EACH ROW
+BEGIN
+ IF NEW.isConciliate = FALSE AND NEW.payed > OLD.payed THEN
+ INSERT INTO vn.mail(`sender`, subject, `body`)
+ SELECT 'finanzas@verdnatura.es',
+ CONCAT(' Cambios de recibos del cliente: ', NEW.clientFk),
+ CONCAT('Se ha cambiado el recibo: ', NEW.Id, ' de ', OLD.payed, ' a ', NEW.payed);
+ END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -35765,6 +36236,8 @@ CREATE TABLE `supplier` (
`withholdingSageFk` smallint(6) DEFAULT NULL COMMENT 'Tipos de retención SAGE',
`transactionTypeSageFk` tinyint(4) DEFAULT NULL COMMENT 'Ti po de transacción SAGE',
`isTrucker` tinyint(1) NOT NULL DEFAULT 0,
+ `supplierActivityFk` varchar(45) NOT NULL DEFAULT 'flowersPlants',
+ `healthRegister` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `cuenta` (`account`),
UNIQUE KEY `NIF` (`nif`),
@@ -35776,13 +36249,15 @@ CREATE TABLE `supplier` (
KEY `supplier_taxTypeFk_idx` (`taxTypeSageFk`),
KEY `supplier_withholdingFk_idx` (`withholdingSageFk`),
KEY `supplier_transactionFk_idx` (`transactionTypeSageFk`),
+ KEY `suppplier_supplierActivityFk` (`supplierActivityFk`),
CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE,
CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE,
CONSTRAINT `supplier_taxTypeFk` FOREIGN KEY (`taxTypeSageFk`) REFERENCES `sage`.`TiposIva` (`CodigoIva`) ON UPDATE CASCADE,
CONSTRAINT `supplier_transactionFk` FOREIGN KEY (`transactionTypeSageFk`) REFERENCES `sage`.`TiposTransacciones` (`CodigoTransaccion`) ON UPDATE CASCADE,
- CONSTRAINT `supplier_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE
+ CONSTRAINT `supplier_withholdingFk` FOREIGN KEY (`withholdingSageFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON UPDATE CASCADE,
+ CONSTRAINT `suppplier_supplierActivityFk` FOREIGN KEY (`supplierActivityFk`) REFERENCES `supplierActivity` (`code`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -35838,6 +36313,20 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
+--
+-- Table structure for table `supplierActivity`
+--
+
+DROP TABLE IF EXISTS `supplierActivity`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `supplierActivity` (
+ `code` varchar(45) CHARACTER SET utf8 NOT NULL,
+ `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
+ PRIMARY KEY (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `supplierContact`
--
@@ -39205,90 +39694,90 @@ DELIMITER ;;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
/*!50003 SET time_zone = 'SYSTEM' */ ;;
-/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN
-
- DECLARE vCurrentCount INT;
- DECLARE vCheckSum INT;
- DECLARE vIsAlreadyNotified BOOLEAN;
- DECLARE vTableQueue TEXT;
- DECLARE vLineQueue TEXT;
- DECLARE vDone BOOL DEFAULT FALSE;
- DECLARE vCur CURSOR FOR
- SELECT CONCAT('
- ', IFNULL(pq.id, ''), ' |
- ', IFNULL(p.path, ''),' |
- ', IFNULL(i.Informe, ''),' |
- ', IFNULL(e.Estado, ''),' |
- ', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' |
- ', IFNULL(pq.`error`, ''),' |
-
')
- FROM vn.printingQueue pq
- LEFT JOIN vn.worker w ON w.id = pq.worker
- LEFT JOIN vn.printer p ON p.id = pq.printer
- LEFT JOIN vn2008.Informes i ON i.Id_Informe = pq.report
- JOIN vn2008.Estados e ON e.Id_Estado = pq.state
- LIMIT 30;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND
- SET vDone = TRUE;
-
- SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum
- FROM vn.printingQueue WHERE state = 1;
-
- SELECT isAlreadyNotified INTO vIsAlreadyNotified
- FROM printingQueueCheck;
-
- IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND
- (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND
- vIsAlreadyNotified = FALSE AND vCurrentCount > 0
- THEN
-
- SELECT '
-
- Id Cola |
- Ruta Impresora |
- Informe |
- Estado |
- Trabajador |
- Error |
-
' INTO vTableQueue;
-
- OPEN vCur;
-
- l: LOOP
-
- SET vDone = FALSE;
-
- FETCH vCur INTO vLineQueue;
-
- IF vDone THEN
- LEAVE l;
- END IF;
-
- SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue;
-
- END LOOP;
-
- CLOSE vCur;
-
- INSERT INTO vn2008.mail (`to`, subject, text)
- VALUES ('cau@verdnatura.es, sysadmin@verdnatura.es',
- 'servidor de impresion parado',
- CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '
'));
-
- UPDATE printingQueueCheck SET isAlreadyNotified = TRUE;
- END IF;
-
- IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND
- vIsAlreadyNotified = TRUE
- THEN
- UPDATE printingQueueCheck SET isAlreadyNotified = FALSE;
- END IF;
-
- UPDATE printingQueueCheck
- SET lastCount = vCurrentCount,
- lastCheckSum = vCheckSum;
-
+/*!50106 CREATE*/ /*!50117 DEFINER=`z-sysadmin`@`%`*/ /*!50106 EVENT `printQueue_check` ON SCHEDULE EVERY 10 MINUTE STARTS '2019-11-08 00:00:00' ON COMPLETION PRESERVE ENABLE COMMENT 'Notifica en caso de que el servidor de impresión este parado' DO BEGIN
+
+ DECLARE vCurrentCount INT;
+ DECLARE vCheckSum INT;
+ DECLARE vIsAlreadyNotified BOOLEAN;
+ DECLARE vTableQueue TEXT;
+ DECLARE vLineQueue TEXT;
+ DECLARE vDone BOOL DEFAULT FALSE;
+ DECLARE vCur CURSOR FOR
+ SELECT CONCAT('
+ ', IFNULL(pq.id, ''), ' |
+ ', IFNULL(p.path, ''),' |
+ ', IFNULL(i.Informe, ''),' |
+ ', IFNULL(e.Estado, ''),' |
+ ', IFNULL(w.firstname, ''), " ", IFNULL(w.lastName, ''),' |
+ ', IFNULL(pq.`error`, ''),' |
+
')
+ FROM vn.printingQueue pq
+ LEFT JOIN vn.worker w ON w.id = pq.worker
+ LEFT JOIN vn.printer p ON p.id = pq.printer
+ LEFT JOIN vn2008.Informes i ON i.Id_Informe = pq.report
+ JOIN vn2008.Estados e ON e.Id_Estado = pq.state
+ LIMIT 30;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND
+ SET vDone = TRUE;
+
+ SELECT COUNT(*), IFNULL(SUM(id),0) INTO vCurrentCount, vCheckSum
+ FROM vn.printingQueue WHERE state = 1;
+
+ SELECT isAlreadyNotified INTO vIsAlreadyNotified
+ FROM printingQueueCheck;
+
+ IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND
+ (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND
+ vIsAlreadyNotified = FALSE AND vCurrentCount > 0
+ THEN
+
+ SELECT '
+
+ Id Cola |
+ Ruta Impresora |
+ Informe |
+ Estado |
+ Trabajador |
+ Error |
+
' INTO vTableQueue;
+
+ OPEN vCur;
+
+ l: LOOP
+
+ SET vDone = FALSE;
+
+ FETCH vCur INTO vLineQueue;
+
+ IF vDone THEN
+ LEAVE l;
+ END IF;
+
+ SELECT CONCAT(vTableQueue, vLineQueue) INTO vTableQueue;
+
+ END LOOP;
+
+ CLOSE vCur;
+
+ INSERT INTO vn2008.mail (`to`, subject, text)
+ VALUES ('cau@verdnatura.es, sysadmin@verdnatura.es',
+ 'servidor de impresion parado',
+ CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas', vTableQueue, '
'));
+
+ UPDATE printingQueueCheck SET isAlreadyNotified = TRUE;
+ END IF;
+
+ IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND
+ vIsAlreadyNotified = TRUE
+ THEN
+ UPDATE printingQueueCheck SET isAlreadyNotified = FALSE;
+ END IF;
+
+ UPDATE printingQueueCheck
+ SET lastCount = vCurrentCount,
+ lastCheckSum = vCheckSum;
+
END */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
@@ -39379,16 +39868,16 @@ DELIMITER ;;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;;
/*!50003 SET @saved_time_zone = @@time_zone */ ;;
/*!50003 SET time_zone = 'SYSTEM' */ ;;
-/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `workerTimeControl_sendMail` ON SCHEDULE EVERY 1 WEEK STARTS '2020-11-25 08:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
- DECLARE vWeek,vYear INT;
-
- SELECT week,year INTO vWeek,vYear
- FROM vn.time
- WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY))
- GROUP BY year,week
- LIMIT 1;
-
- CALL vn.workerTimeControl_sendMail(vWeek, vYear, NULL);
+/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `workerTimeControl_sendMail` ON SCHEDULE EVERY 1 WEEK STARTS '2020-11-25 08:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN
+ DECLARE vWeek,vYear INT;
+
+ SELECT week,year INTO vWeek,vYear
+ FROM vn.time
+ WHERE dated IN (DATE_ADD(CURDATE(), INTERVAL -10 DAY), DATE_ADD(CURDATE(), INTERVAL -4 DAY))
+ GROUP BY year,week
+ LIMIT 1;
+
+ CALL vn.workerTimeControl_sendMail(vWeek, vYear, NULL);
END */ ;;
/*!50003 SET time_zone = @saved_time_zone */ ;;
/*!50003 SET sql_mode = @saved_sql_mode */ ;;
@@ -39672,15 +40161,15 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`%` FUNCTION `botanicExport_isUpdatable`(vVnGenusFk MEDIUMINT,vVnSpecieFk MEDIUMINT,
+CREATE DEFINER=`root`@`%` FUNCTION `botanicExport_isUpdatable`(vEdiGenusFk MEDIUMINT,vEdiSpecieFk MEDIUMINT,
vCountryFk MEDIUMINT,vRestriction MEDIUMINT) RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE vIsUpdatable INTEGER;
SELECT COUNT(*) INTO vIsUpdatable
FROM botanicExport
- WHERE vnGenusFk = vVnGenusFk
- AND (vVnSpecieFk = vnSpecieFk OR IFNULL(vVnSpecieFk,vnSpecieFk) IS NULL)
+ WHERE ediGenusFk = vEdiGenusFk
+ AND (vEdiSpecieFk = ediSpecieFk OR IFNULL(vEdiSpecieFk,ediSpecieFk) IS NULL)
AND (vCountryFk = countryFk OR IFNULL(vCountryFk,countryFk) IS NULL)
AND vRestriction = restriction;
RETURN vIsUpdatable;
@@ -39779,8 +40268,8 @@ BEGIN
SELECT COUNT(*) INTO vHasPassport
FROM botanicExport be
JOIN itemBotanical ib
- ON be.vnGenusFk = ib.genusFk
- AND IFNULL(be.vnSpecieFk, ib.specieFk) = ib.specieFk
+ ON be.ediGenusFk = ib.genusFk
+ AND IFNULL(be.ediSpecieFk, ib.specieFk) = ib.specieFk
AND be.`code` = 'phytosanitaryPassport'
JOIN item i ON i.id = ib.itemFk
JOIN itemType it ON it.id = i.typeFk
@@ -40558,71 +41047,71 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` FUNCTION `ekt_getEntry`(vEktFk INT) RETURNS int(11)
READS SQL DATA
-BEGIN
- DECLARE vTravelFk INT;
- DECLARE vEntryFk INT DEFAULT 0;
- DECLARE vEntryAssignFk INT;
-
- SET vTravelFk = vn.ekt_getTravel(vEktFk);
-
- IF vTravelFk THEN
-
- SELECT ea.id INTO vEntryAssignFk
- FROM edi.ekt e
- JOIN vn.travel tr ON tr.id = vTravelFk
- JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk
- AND ea.warehouseInFk = tr.warehouseInFk
- AND ea.agencyModeFk = tr.agencyFk
- AND IFNULL(ea.sub, e.sub) <=> e.sub
- AND IFNULL(ea.kop, e.kop) <=> e.kop
- AND IFNULL(ea.pro, e.pro) <=> e.pro
- WHERE e.id = vEktFk
- ORDER BY ea.sub <=> e.sub AND ea.kop <=> e.kop AND ea.pro <=> e.pro DESC,
- ea.sub <=> e.sub AND ea.kop <=> e.kop AND ISNULL(ea.pro) DESC,
- ea.sub <=> e.sub AND ISNULL(ea.kop) AND ea.pro <=> e.pro DESC,
- ea.sub <=> e.sub AND ISNULL(ea.kop) AND ISNULL(ea.pro) DESC,
- ISNULL(ea.sub) AND ea.kop <=> e.kop AND ea.pro <=> e.pro DESC,
- ISNULL(ea.sub) AND ea.kop <=> e.kop AND ISNULL(ea.pro) DESC,
- ISNULL(ea.sub) AND ISNULL(ea.kop) AND ea.pro <=> e.pro DESC
- LIMIT 1;
-
- SELECT MAX(e.id) INTO vEntryFk
- FROM vn.entry e
- JOIN vn.ektEntryAssign ea ON ea.id = vEntryAssignFk
- WHERE e.travelFk = vTravelFk
- AND e.sub <=> ea.sub
- AND e.kop <=> ea.kop
- AND e.pro <=> ea.pro;
-
-
- IF IFNULL(vEntryFk,0) = 0 THEN
-
- INSERT INTO vn.entry(travelFk, supplierFk, companyFk, currencyFk, kop, sub, ref, pro)
- SELECT vTravelFk, ea.supplierFk, c.id, cu.id, ea.kop, ea.sub, ea.ref, ea.pro
- FROM vn.ektEntryAssign ea
- JOIN vn.company c ON c.code = 'VNL'
- JOIN vn.currency cu ON cu.code = 'EUR'
- WHERE ea.id = vEntryAssignFk;
-
- SELECT MAX(id) INTO vEntryFk
- FROM vn.entry
- WHERE travelFk = vTravelFk;
-
- END IF;
-
- UPDATE vn.ektEntryAssign
- SET entryFk = vEntryFk
- WHERE id = vEntryAssignFk;
-
- ELSE
-
+BEGIN
+ DECLARE vTravelFk INT;
+ DECLARE vEntryFk INT DEFAULT 0;
+ DECLARE vEntryAssignFk INT;
+
+ SET vTravelFk = vn.ekt_getTravel(vEktFk);
+
+ IF vTravelFk THEN
+
+ SELECT ea.id INTO vEntryAssignFk
+ FROM edi.ekt e
+ JOIN vn.travel tr ON tr.id = vTravelFk
+ JOIN vn.ektEntryAssign ea ON ea.warehouseOutFk = tr.warehouseOutFk
+ AND ea.warehouseInFk = tr.warehouseInFk
+ AND ea.agencyModeFk = tr.agencyFk
+ AND IFNULL(ea.sub, e.sub) <=> e.sub
+ AND IFNULL(ea.kop, e.kop) <=> e.kop
+ AND IFNULL(ea.pro, e.pro) <=> e.pro
+ WHERE e.id = vEktFk
+ ORDER BY ea.sub <=> e.sub AND ea.kop <=> e.kop AND ea.pro <=> e.pro DESC,
+ ea.sub <=> e.sub AND ea.kop <=> e.kop AND ISNULL(ea.pro) DESC,
+ ea.sub <=> e.sub AND ISNULL(ea.kop) AND ea.pro <=> e.pro DESC,
+ ea.sub <=> e.sub AND ISNULL(ea.kop) AND ISNULL(ea.pro) DESC,
+ ISNULL(ea.sub) AND ea.kop <=> e.kop AND ea.pro <=> e.pro DESC,
+ ISNULL(ea.sub) AND ea.kop <=> e.kop AND ISNULL(ea.pro) DESC,
+ ISNULL(ea.sub) AND ISNULL(ea.kop) AND ea.pro <=> e.pro DESC
+ LIMIT 1;
+
+ SELECT MAX(e.id) INTO vEntryFk
+ FROM vn.entry e
+ JOIN vn.ektEntryAssign ea ON ea.id = vEntryAssignFk
+ WHERE e.travelFk = vTravelFk
+ AND e.sub <=> ea.sub
+ AND e.kop <=> ea.kop
+ AND e.pro <=> ea.pro;
+
+
+ IF IFNULL(vEntryFk,0) = 0 THEN
+
+ INSERT INTO vn.entry(travelFk, supplierFk, companyFk, currencyFk, kop, sub, ref, pro)
+ SELECT vTravelFk, ea.supplierFk, c.id, cu.id, ea.kop, ea.sub, ea.ref, ea.pro
+ FROM vn.ektEntryAssign ea
+ JOIN vn.company c ON c.code = 'VNL'
+ JOIN vn.currency cu ON cu.code = 'EUR'
+ WHERE ea.id = vEntryAssignFk;
+
+ SELECT MAX(id) INTO vEntryFk
+ FROM vn.entry
+ WHERE travelFk = vTravelFk;
+
+ END IF;
+
+ UPDATE vn.ektEntryAssign
+ SET entryFk = vEntryFk
+ WHERE id = vEntryAssignFk;
+
+ ELSE
+
SET vEntryFk = 9200;
INSERT IGNORE INTO vn.entry(id) VALUES(vEntryFk);
-
- END IF;
-
- RETURN vEntryFk;
+
+ END IF;
+
+ RETURN vEntryFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -42121,19 +42610,19 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `isLogifloraDay`(vShipped DATE, vWarehouse INT) RETURNS tinyint(1)
DETERMINISTIC
-BEGIN
-
- DECLARE vIsLogifloraDay BOOLEAN;
-
- SELECT COUNT(*) INTO vIsLogifloraDay
- FROM edi.warehouseFloramondo wf
- JOIN vn.floramondoConfig fc
- WHERE wf.warehouseFk = vWarehouse
+BEGIN
+
+ DECLARE vIsLogifloraDay BOOLEAN;
+
+ SELECT COUNT(*) INTO vIsLogifloraDay
+ FROM edi.warehouseFloramondo wf
+ JOIN vn.floramondoConfig fc
+ WHERE wf.warehouseFk = vWarehouse
AND vShipped BETWEEN DATE(TIMESTAMPADD(DAY, wf.travellingDays , fc.nextLanded))
- AND DATE(TIMESTAMPADD(DAY, wf.travellingDays + wf.dayRange , fc.nextLanded));
-
- RETURN vIsLogifloraDay;
-
+ AND DATE(TIMESTAMPADD(DAY, wf.travellingDays + wf.dayRange , fc.nextLanded));
+
+ RETURN vIsLogifloraDay;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -42337,17 +42826,17 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `item_getFhImage`(itemFk INT) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
DETERMINISTIC
-BEGIN
- DECLARE vImageUrl VARCHAR(255);
- SELECT sr.PictureReference INTO vImageUrl
- FROM vn.buy b
- JOIN edi.ekt e ON b.ektFk = e.id
- JOIN edi.supplyResponse sr ON sr.Item_ArticleCode =e.`ref`
- JOIN vn.item i ON i.id = b.itemFk
- WHERE b.itemFk = itemFk
- ORDER BY (sr.EmbalageCode = e.package) DESC
- LIMIT 1;
- RETURN vImageUrl;
+BEGIN
+ DECLARE vImageUrl VARCHAR(255);
+ SELECT sr.PictureReference INTO vImageUrl
+ FROM vn.buy b
+ JOIN edi.ekt e ON b.ektFk = e.id
+ JOIN edi.supplyResponse sr ON sr.Item_ArticleCode =e.`ref`
+ JOIN vn.item i ON i.id = b.itemFk
+ WHERE b.itemFk = itemFk
+ ORDER BY (sr.EmbalageCode = e.package) DESC
+ LIMIT 1;
+ RETURN vImageUrl;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -42666,12 +43155,12 @@ FROM
JOIN
botanicExport be ON be.`code` = 'phytosanitaryPassport'
LEFT JOIN
- vnGenus vg ON vg.id = be.vnGenusFk
+ ediGenus eg ON eg.id = be.ediGenusFk
LEFT JOIN
- vnSpecie vs ON vs.id = be.vnSpecieFk
+ ediSpecie es ON es.id = be.ediSpecieFk
WHERE
t.refFk = vRef
- AND ib.ediBotanic LIKE CONCAT(IFNULL(vg.latinGenusName, ''),
+ AND ib.ediBotanic LIKE CONCAT(IFNULL(eg.latinGenusName, ''),
IF(latinSpeciesName > '',
CONCAT(' ', latinSpeciesName),
''),
@@ -43400,13 +43889,13 @@ DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`z-sysadmin`@`%` FUNCTION `time_getSalesYear`(vMonth INT, vYear INT) RETURNS int(11)
DETERMINISTIC
-BEGIN
-DECLARE vSalesYear INT;
-SELECT salesYear INTO vSalesYear
-FROM `time`
-WHERE `month` = vMonth AND `year` = vYear
-LIMIT 1;
-RETURN vSalesYear;
+BEGIN
+DECLARE vSalesYear INT;
+SELECT salesYear INTO vSalesYear
+FROM `time`
+WHERE `month` = vMonth AND `year` = vYear
+LIMIT 1;
+RETURN vSalesYear;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -44127,23 +44616,23 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` PROCEDURE `agencyVolume`(vDated DATE, vAgency INT)
-BEGIN
-
- SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- INNER JOIN vn.entry e ON e.id = b.entryFk
- INNER JOIN vn.travel tr ON tr.id = e.travelFk
- INNER JOIN vn.volumeConfig vc
- INNER JOIN vn.item i ON i.id = b.itemFk
- INNER JOIN vn.itemType it ON it.id = i.typeFk
- WHERE tr.landed = vDated
- AND tr.agencyFk IN (0, vAgency)
- GROUP BY Temp;
-
+BEGIN
+
+ SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
+ FROM vn.buy b
+ INNER JOIN vn.entry e ON e.id = b.entryFk
+ INNER JOIN vn.travel tr ON tr.id = e.travelFk
+ INNER JOIN vn.volumeConfig vc
+ INNER JOIN vn.item i ON i.id = b.itemFk
+ INNER JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE tr.landed = vDated
+ AND tr.agencyFk IN (0, vAgency)
+ GROUP BY Temp;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -44752,14 +45241,14 @@ BEGIN
', Packing: ', IFNULL(vPacking, 0),
', Nombre: ', IFNULL(i.`name`, 0),
', buy_edi: ', IFNULL(e.id, 0),
- ', Nombre botánico: ', IFNULL(g.name, ''), ' ', IFNULL(s.name, ''),
+ ', Nombre botánico: ', IFNULL(g.latin_genus_name, ''), ' ', IFNULL(s.latin_species_name, ''),
', Productor: ',IFNULL(es.company_name, IFNULL(p.`name`, ''))
)
,'ekt@verdnatura.es'
FROM item i
LEFT JOIN itemBotanical ib ON ib.itemFk = i.id
- LEFT JOIN vn.genus g ON g.id = ib.genusFk
- LEFT JOIN vn.specie s ON IFNULL(s.specie_id, ib.specieFk) = ib.specieFk
+ LEFT JOIN edi.genus g ON g.genus_id = ib.genusFk
+ LEFT JOIN edi.specie s ON IFNULL(s.specie_id, ib.specieFk) = ib.specieFk
LEFT JOIN producer p ON p.id = i.producerFk
LEFT JOIN buy b ON b.id = vBuyFk
LEFT JOIN edi.ekt e ON b.ektFk = e.id
@@ -46138,87 +46627,87 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `clean_logiflora`()
-BEGIN
+BEGIN
/* partir en 2 procedimientos, uno que borre compras y otro articulos
* item_clean, buy_clean
* */
- DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, CURDATE());
- DECLARE vDone INT DEFAULT FALSE;
- DECLARE vBuyFk INT;
- DECLARE cur1 CURSOR FOR SELECT id FROM tmp.buy;
+ DECLARE vMaxDated DATE DEFAULT TIMESTAMPADD(DAY, - 7, CURDATE());
+ DECLARE vDone INT DEFAULT FALSE;
+ DECLARE vBuyFk INT;
+ DECLARE cur1 CURSOR FOR SELECT id FROM tmp.buy;
DECLARE cur2 CURSOR FOR SELECT id FROM tmp.item;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.buy;
-
- CREATE TEMPORARY TABLE tmp.buy
- ENGINE = MEMORY
- SELECT b.id
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- JOIN vn.agencyMode am ON am.id = tr.agencyFk
- WHERE b.quantity = 0
- AND am.name = 'LOGIFLORA'
- AND e.isRaid;
-
- OPEN cur1;
-
- read_loop: LOOP
-
- SET vDone = FALSE;
-
- FETCH cur1 INTO vBuyFk;
-
- IF vDone THEN
- LEAVE read_loop;
- END IF;
-
- DELETE FROM vn.buy WHERE id = vBuyFk;
-
- END LOOP;
-
- CLOSE cur1;
-
- DROP TEMPORARY TABLE tmp.buy;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.item;
-
- CREATE TEMPORARY TABLE tmp.item
- ENGINE = MEMORY
- SELECT DISTINCT i.id
- FROM vn.item i
- LEFT JOIN hedera.orderRow o ON o.itemFk = i.id
- LEFT JOIN vn.sale s ON s.itemFk = i.id
- LEFT JOIN vn.buy b ON b.itemFk = i.id
- WHERE i.supplyResponseFk
- AND o.id IS NULL
- AND b.id IS NULL
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.buy;
+
+ CREATE TEMPORARY TABLE tmp.buy
+ ENGINE = MEMORY
+ SELECT b.id
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.agencyMode am ON am.id = tr.agencyFk
+ WHERE b.quantity = 0
+ AND am.name = 'LOGIFLORA'
+ AND e.isRaid;
+
+ OPEN cur1;
+
+ read_loop: LOOP
+
+ SET vDone = FALSE;
+
+ FETCH cur1 INTO vBuyFk;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+
+ DELETE FROM vn.buy WHERE id = vBuyFk;
+
+ END LOOP;
+
+ CLOSE cur1;
+
+ DROP TEMPORARY TABLE tmp.buy;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.item;
+
+ CREATE TEMPORARY TABLE tmp.item
+ ENGINE = MEMORY
+ SELECT DISTINCT i.id
+ FROM vn.item i
+ LEFT JOIN hedera.orderRow o ON o.itemFk = i.id
+ LEFT JOIN vn.sale s ON s.itemFk = i.id
+ LEFT JOIN vn.buy b ON b.itemFk = i.id
+ WHERE i.supplyResponseFk
+ AND o.id IS NULL
+ AND b.id IS NULL
AND s.id IS NULL
- AND i.created < vMaxDated;
-
- OPEN cur2;
-
- read_loop: LOOP
-
- SET vDone = FALSE;
-
- FETCH cur2 INTO vBuyFk;
-
- IF vDone THEN
- LEAVE read_loop;
- END IF;
-
- DELETE FROM vn.item WHERE id = vBuyFk;
-
- END LOOP;
-
- CLOSE cur2;
-
- DROP TEMPORARY TABLE tmp.item;
-
+ AND i.created < vMaxDated;
+
+ OPEN cur2;
+
+ read_loop: LOOP
+
+ SET vDone = FALSE;
+
+ FETCH cur2 INTO vBuyFk;
+
+ IF vDone THEN
+ LEAVE read_loop;
+ END IF;
+
+ DELETE FROM vn.item WHERE id = vBuyFk;
+
+ END LOOP;
+
+ CLOSE cur2;
+
+ DROP TEMPORARY TABLE tmp.item;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -50875,15 +51364,15 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` PROCEDURE `ediTables_Update`()
-BEGIN
-
- INSERT IGNORE INTO vn.genus(name)
- SELECT name
- FROM vn.genus ;
-
- INSERT IGNORE INTO vn.specie(name)
- SELECT LCASE(name)
- FROM vn.specie ;
+BEGIN
+
+ INSERT IGNORE INTO vn.genus(name)
+ SELECT latin_genus_name
+ FROM edi.genus ;
+
+ INSERT IGNORE INTO vn.specie(name)
+ SELECT LCASE(latin_species_name)
+ FROM edi.specie ;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51026,65 +51515,65 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `ekt_add`(vPutOrderFk INT)
-BEGIN
-
-/**
- * Añade ekt para las ordenes de compra de proveedores que no envian el ekt por email
- *
- * @param vPutOrderFk PutOrderId de donde coger los datos
- **/
-
- INSERT INTO edi.ekt(entryYear,
- deliveryNumber,
- fec,
- hor,
- item,
- pac,
- qty,
- ori,
- cat,
- pro,
- pri,
- package,
- s1,
- s2,
- s3,
- s4,
- s5,
- s6,
- putOrderFk,
+BEGIN
+
+/**
+ * Añade ekt para las ordenes de compra de proveedores que no envian el ekt por email
+ *
+ * @param vPutOrderFk PutOrderId de donde coger los datos
+ **/
+
+ INSERT INTO edi.ekt(entryYear,
+ deliveryNumber,
+ fec,
+ hor,
+ item,
+ pac,
+ qty,
+ ori,
+ cat,
+ pro,
+ pri,
+ package,
+ s1,
+ s2,
+ s3,
+ s4,
+ s5,
+ s6,
+ putOrderFk,
`ref`,
- kop)
- SELECT year(curdate()) entryYear,
- p.id deliveryNumber ,
- CURDATE() fec,
- CURTIME() hor,
- i.longName item,
- sr.NumberOfItemsPerCask pac,
- p.quantity qty,
- o.code ori,
- i.category cat,
- mp.supplierFk pro,
- sr.Price pri,
- sr.EmbalageCode package,
- i.value5 s1,
- i.value6 s2,
- i.value7 s3,
- i.value8 s4,
- i.value9 s5,
- i.value10 s6,
- p.id putOrderFk,
+ kop)
+ SELECT year(curdate()) entryYear,
+ p.id deliveryNumber ,
+ CURDATE() fec,
+ CURTIME() hor,
+ i.longName item,
+ sr.NumberOfItemsPerCask pac,
+ p.quantity qty,
+ o.code ori,
+ i.category cat,
+ mp.supplierFk pro,
+ sr.Price pri,
+ sr.EmbalageCode package,
+ i.value5 s1,
+ i.value6 s2,
+ i.value7 s3,
+ i.value8 s4,
+ i.value9 s5,
+ i.value10 s6,
+ p.id putOrderFk,
sr.Item_ArticleCode,
- sr.vmpID
- FROM edi.putOrder p
- JOIN edi.supplyResponse sr ON sr.ID = p.supplyResponseID
- JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
- JOIN vn.item i ON i.supplyResponseFk = sr.ID
- JOIN vn.origin o ON o.id = i.originFk
- WHERE p.id = vPutOrderFk;
-
- CALL edi.ekt_load(LAST_INSERT_ID());
-
+ sr.vmpID
+ FROM edi.putOrder p
+ JOIN edi.supplyResponse sr ON sr.ID = p.supplyResponseID
+ JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
+ JOIN vn.item i ON i.supplyResponseFk = sr.ID
+ JOIN vn.origin o ON o.id = i.originFk
+ WHERE p.id = vPutOrderFk;
+
+ CALL edi.ekt_load(LAST_INSERT_ID());
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51135,216 +51624,216 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `entryConverter`(IN `vEntry` INT)
-BEGIN
-
- DECLARE vWarehouseIn INT;
- DECLARE vWarehouseOut INT;
- DECLARE vTravel INT;
-
- DECLARE done BOOL DEFAULT FALSE;
-
- DECLARE vId_Entrada INT;
- DECLARE vId_Article INT;
- DECLARE vEtiquetas INT;
- DECLARE vId_Cubo VARCHAR(10);
- DECLARE vPacking INT;
- DECLARE vGrouping INT;
- DECLARE vCantidad INT;
- DECLARE vCostefijo DECIMAL(10,3);
- DECLARE vPortefijo DECIMAL(10,3);
- DECLARE vEmbalajefijo DECIMAL(10);
- DECLARE vComisionfija DECIMAL(10,3);
- DECLARE vCaja INT;
- DECLARE vNicho VARCHAR(5);
- DECLARE vTarifa1 DECIMAL(10,2);
- DECLARE vTarifa2 DECIMAL(10,2);
- DECLARE vTarifa3 DECIMAL(10,2);
- DECLARE vPVP DECIMAL(10,2);
- DECLARE vCompra INT;
-
- DECLARE rs CURSOR FOR
- SELECT
- b.Id_Entrada,
- b.Id_Article,
- b.Etiquetas,
- b.Id_Cubo,
- b.Packing,
- b.`grouping`,
- b.Cantidad,
- b.Costefijo,
- b.Portefijo,
- b.Embalajefijo,
- b.Comisionfija,
- b.caja,
- b.Nicho,
- b.Tarifa1,
- b.Tarifa2,
- b.Tarifa3,
- b.PVP
- FROM vn2008.Compres b
- JOIN vn.itemConversor ic ON ic.espItemFk = b.Id_Article
- WHERE Id_Entrada = vEntry;
-
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-
- SELECT warehouseInFk, warehouseOutFk, tr.id
- INTO vWarehouseIn, vWarehouseOut, vTravel
- FROM travel tr
- JOIN entry e ON e.travelFk = tr.id
- WHERE e.id = vEntry;
-
- UPDATE travel
- SET warehouseInFk = vWarehouseOut,
- warehouseOutFk = vWarehouseIn
- WHERE id = vTravel;
-
- UPDATE vn2008.Compres c
- LEFT JOIN vn.itemConversor ic ON ic.espItemFk = c.Id_Article
- SET Etiquetas = 0, Cantidad = 0
- WHERE c.Id_Entrada = vEntry
- AND ic.espItemFk IS NULL;
-
- OPEN rs;
-
- DELETE FROM vn2008.Compres WHERE Id_Entrada = vEntry;
-
- FETCH rs INTO
- vId_Entrada,
- vId_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP;
-
- WHILE NOT done DO
-
- -- Primero la linea original con las cantidades invertidas
- INSERT INTO vn2008.Compres
- (
- Id_Entrada,
- Id_Article,
- Etiquetas,
- Id_Cubo,
- Packing,
- `grouping`,
- Cantidad,
- Costefijo,
- Portefijo,
- Embalajefijo,
- Comisionfija,
- caja,
- Nicho,
- Tarifa1,
- Tarifa2,
- Tarifa3,
- PVP
- )
- VALUES
- (
- vId_Entrada,
- vId_Article,
- - vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- - vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP);
-
- -- Ahora la linea nueva, con el item genérico
- INSERT INTO vn2008.Compres
- (
- Id_Entrada,
- Id_Article,
- Etiquetas,
- Id_Cubo,
- Packing,
- `grouping`,
- Cantidad,
- Costefijo,
- Portefijo,
- Embalajefijo,
- Comisionfija,
- caja,
- Nicho,
- Tarifa1,
- Tarifa2,
- Tarifa3,
- PVP
- )
- SELECT
- vId_Entrada,
- genItemFk as Id_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP
- FROM itemConversor
- WHERE espItemFk = vId_Article;
-
- SELECT LAST_INSERT_ID()
- INTO vCompra;
-
- REPLACE vn2008.Compres_mark(Id_Compra,`comment`)
- SELECT vCompra, vId_Article;
-
-
- FETCH rs INTO
- vId_Entrada,
- vId_Article,
- vEtiquetas,
- vId_Cubo,
- vPacking,
- vGrouping,
- vCantidad,
- vCostefijo,
- vPortefijo,
- vEmbalajefijo,
- vComisionfija,
- vCaja,
- vNicho,
- vTarifa1,
- vTarifa2,
- vTarifa3,
- vPVP;
-
- END WHILE;
-
-
- CLOSE rs;
-
-
-
+BEGIN
+
+ DECLARE vWarehouseIn INT;
+ DECLARE vWarehouseOut INT;
+ DECLARE vTravel INT;
+
+ DECLARE done BOOL DEFAULT FALSE;
+
+ DECLARE vId_Entrada INT;
+ DECLARE vId_Article INT;
+ DECLARE vEtiquetas INT;
+ DECLARE vId_Cubo VARCHAR(10);
+ DECLARE vPacking INT;
+ DECLARE vGrouping INT;
+ DECLARE vCantidad INT;
+ DECLARE vCostefijo DECIMAL(10,3);
+ DECLARE vPortefijo DECIMAL(10,3);
+ DECLARE vEmbalajefijo DECIMAL(10);
+ DECLARE vComisionfija DECIMAL(10,3);
+ DECLARE vCaja INT;
+ DECLARE vNicho VARCHAR(5);
+ DECLARE vTarifa1 DECIMAL(10,2);
+ DECLARE vTarifa2 DECIMAL(10,2);
+ DECLARE vTarifa3 DECIMAL(10,2);
+ DECLARE vPVP DECIMAL(10,2);
+ DECLARE vCompra INT;
+
+ DECLARE rs CURSOR FOR
+ SELECT
+ b.Id_Entrada,
+ b.Id_Article,
+ b.Etiquetas,
+ b.Id_Cubo,
+ b.Packing,
+ b.`grouping`,
+ b.Cantidad,
+ b.Costefijo,
+ b.Portefijo,
+ b.Embalajefijo,
+ b.Comisionfija,
+ b.caja,
+ b.Nicho,
+ b.Tarifa1,
+ b.Tarifa2,
+ b.Tarifa3,
+ b.PVP
+ FROM vn2008.Compres b
+ JOIN vn.itemConversor ic ON ic.espItemFk = b.Id_Article
+ WHERE Id_Entrada = vEntry;
+
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
+
+ SELECT warehouseInFk, warehouseOutFk, tr.id
+ INTO vWarehouseIn, vWarehouseOut, vTravel
+ FROM travel tr
+ JOIN entry e ON e.travelFk = tr.id
+ WHERE e.id = vEntry;
+
+ UPDATE travel
+ SET warehouseInFk = vWarehouseOut,
+ warehouseOutFk = vWarehouseIn
+ WHERE id = vTravel;
+
+ UPDATE vn2008.Compres c
+ LEFT JOIN vn.itemConversor ic ON ic.espItemFk = c.Id_Article
+ SET Etiquetas = 0, Cantidad = 0
+ WHERE c.Id_Entrada = vEntry
+ AND ic.espItemFk IS NULL;
+
+ OPEN rs;
+
+ DELETE FROM vn2008.Compres WHERE Id_Entrada = vEntry;
+
+ FETCH rs INTO
+ vId_Entrada,
+ vId_Article,
+ vEtiquetas,
+ vId_Cubo,
+ vPacking,
+ vGrouping,
+ vCantidad,
+ vCostefijo,
+ vPortefijo,
+ vEmbalajefijo,
+ vComisionfija,
+ vCaja,
+ vNicho,
+ vTarifa1,
+ vTarifa2,
+ vTarifa3,
+ vPVP;
+
+ WHILE NOT done DO
+
+ -- Primero la linea original con las cantidades invertidas
+ INSERT INTO vn2008.Compres
+ (
+ Id_Entrada,
+ Id_Article,
+ Etiquetas,
+ Id_Cubo,
+ Packing,
+ `grouping`,
+ Cantidad,
+ Costefijo,
+ Portefijo,
+ Embalajefijo,
+ Comisionfija,
+ caja,
+ Nicho,
+ Tarifa1,
+ Tarifa2,
+ Tarifa3,
+ PVP
+ )
+ VALUES
+ (
+ vId_Entrada,
+ vId_Article,
+ - vEtiquetas,
+ vId_Cubo,
+ vPacking,
+ vGrouping,
+ - vCantidad,
+ vCostefijo,
+ vPortefijo,
+ vEmbalajefijo,
+ vComisionfija,
+ vCaja,
+ vNicho,
+ vTarifa1,
+ vTarifa2,
+ vTarifa3,
+ vPVP);
+
+ -- Ahora la linea nueva, con el item genérico
+ INSERT INTO vn2008.Compres
+ (
+ Id_Entrada,
+ Id_Article,
+ Etiquetas,
+ Id_Cubo,
+ Packing,
+ `grouping`,
+ Cantidad,
+ Costefijo,
+ Portefijo,
+ Embalajefijo,
+ Comisionfija,
+ caja,
+ Nicho,
+ Tarifa1,
+ Tarifa2,
+ Tarifa3,
+ PVP
+ )
+ SELECT
+ vId_Entrada,
+ genItemFk as Id_Article,
+ vEtiquetas,
+ vId_Cubo,
+ vPacking,
+ vGrouping,
+ vCantidad,
+ vCostefijo,
+ vPortefijo,
+ vEmbalajefijo,
+ vComisionfija,
+ vCaja,
+ vNicho,
+ vTarifa1,
+ vTarifa2,
+ vTarifa3,
+ vPVP
+ FROM itemConversor
+ WHERE espItemFk = vId_Article;
+
+ SELECT LAST_INSERT_ID()
+ INTO vCompra;
+
+ REPLACE vn2008.Compres_mark(Id_Compra,`comment`)
+ SELECT vCompra, vId_Article;
+
+
+ FETCH rs INTO
+ vId_Entrada,
+ vId_Article,
+ vEtiquetas,
+ vId_Cubo,
+ vPacking,
+ vGrouping,
+ vCantidad,
+ vCostefijo,
+ vPortefijo,
+ vEmbalajefijo,
+ vComisionfija,
+ vCaja,
+ vNicho,
+ vTarifa1,
+ vTarifa2,
+ vTarifa3,
+ vPVP;
+
+ END WHILE;
+
+
+ CLOSE rs;
+
+
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51406,62 +51895,62 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `entryPrepare`(IN `idE` BIGINT)
-BEGIN
- SELECT
- b.quantity / b.packing AS Paquetes,
- b.packing AS `Grouping`,
- barcode,
- 'ASEGURADO' AS asegurado,
- ic.name,
- ic.order,
- s.name AS Consignatario,
- e.supplierFk AS Id_Cliente,
- e.isOrdered,
- e.isConfirmed,
- 10 AS Calidad,
- LPAD(IFNULL(cpd.id, ip.code),
- 5,
- '0') AS path,
- b.entryFk AS Id_Ticket,
- t.landed AS Fecha,
- b.itemFk,
- b.quantity,
- i.name AS Concepte,
- i.size,
- i.inkFk,
- i.category,
- o.code AS Origen,
- 0 AS Bultos,
- wIn.`name` AS Tipo,
- 0 AS OK,
- 0 AS Reservado,
- i.stems,
- b.id AS Id_Movimiento,
- ip.code,
- 'PEDIDO ASEGURADO' AS MSG,
- 0 AS Seguro,
- i.image,
- pr.name AS producer
- FROM vn.buy b
- JOIN vn.entry e ON b.entryFk = e.id
- JOIN vn.travel t ON t.id = e.travelFk
- JOIN vn.warehouse wIn ON wIn.id = t.warehouseInFk
- JOIN vn.warehouse wOut ON wOut.id = t.warehouseOutFk
- JOIN vn.item i ON i.id = b.itemFk
- JOIN vn.itemType it ON it.id =i.typeFk
- JOIN vn.itemCategory ic ON ic.id = it.categoryFk
- JOIN vn.packaging pkg ON pkg.id = b.packageFk
- LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = wIn.id AND ip.warehouseFk = t.warehouseOutFk
- LEFT JOIN (SELECT itemFk, code AS barcode FROM vn.itemBarcode GROUP BY itemFk) ib ON ib.itemFk = b.itemFk
- LEFT JOIN vn.origin o ON o.id = i.originFk
- LEFT JOIN vn.supplier s ON s.id = e.supplierFk
- LEFT JOIN vn.producer pr on pr.id = i.producerFk
- LEFT JOIN vn.coolerPathDetail cpd ON LEFT(ip.code, 3) = cpd.hallway
- WHERE
- NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid
- AND e.id = 158772
- AND i.typeFk IS NOT NULL
- AND ic.merchandise IS NOT FALSE;
+BEGIN
+ SELECT
+ b.quantity / b.packing AS Paquetes,
+ b.packing AS `Grouping`,
+ barcode,
+ 'ASEGURADO' AS asegurado,
+ ic.name,
+ ic.order,
+ s.name AS Consignatario,
+ e.supplierFk AS Id_Cliente,
+ e.isOrdered,
+ e.isConfirmed,
+ 10 AS Calidad,
+ LPAD(IFNULL(cpd.id, ip.code),
+ 5,
+ '0') AS path,
+ b.entryFk AS Id_Ticket,
+ t.landed AS Fecha,
+ b.itemFk,
+ b.quantity,
+ i.name AS Concepte,
+ i.size,
+ i.inkFk,
+ i.category,
+ o.code AS Origen,
+ 0 AS Bultos,
+ wIn.`name` AS Tipo,
+ 0 AS OK,
+ 0 AS Reservado,
+ i.stems,
+ b.id AS Id_Movimiento,
+ ip.code,
+ 'PEDIDO ASEGURADO' AS MSG,
+ 0 AS Seguro,
+ i.image,
+ pr.name AS producer
+ FROM vn.buy b
+ JOIN vn.entry e ON b.entryFk = e.id
+ JOIN vn.travel t ON t.id = e.travelFk
+ JOIN vn.warehouse wIn ON wIn.id = t.warehouseInFk
+ JOIN vn.warehouse wOut ON wOut.id = t.warehouseOutFk
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN vn.itemType it ON it.id =i.typeFk
+ JOIN vn.itemCategory ic ON ic.id = it.categoryFk
+ JOIN vn.packaging pkg ON pkg.id = b.packageFk
+ LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND ip.warehouseFk = wIn.id AND ip.warehouseFk = t.warehouseOutFk
+ LEFT JOIN (SELECT itemFk, code AS barcode FROM vn.itemBarcode GROUP BY itemFk) ib ON ib.itemFk = b.itemFk
+ LEFT JOIN vn.origin o ON o.id = i.originFk
+ LEFT JOIN vn.supplier s ON s.id = e.supplierFk
+ LEFT JOIN vn.producer pr on pr.id = i.producerFk
+ LEFT JOIN vn.coolerPathDetail cpd ON LEFT(ip.code, 3) = cpd.hallway
+ WHERE
+ NOT wIn.isFeedStock AND NOT e.isInventory AND NOT e.isRaid
+ AND e.id = 158772
+ AND i.typeFk IS NOT NULL
+ AND ic.merchandise IS NOT FALSE;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -51552,22 +52041,22 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` PROCEDURE `entryVolume`(vEntryFk INT)
-BEGIN
-
- SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- INNER JOIN vn.entry e ON e.id = b.entryFk
- INNER JOIN vn.travel tr ON tr.id = e.travelFk
- INNER JOIN vn.volumeConfig vc
- INNER JOIN vn.item i ON i.id = b.itemFk
- INNER JOIN vn.itemType it ON it.id = i.typeFk
- WHERE e.id = vEntryFk
- GROUP BY Temp;
-
+BEGIN
+
+ SELECT ELT(it.temperature + 1,'Calientes','Frios','Secos') AS Temp,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS carros ,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
+ FROM vn.buy b
+ INNER JOIN vn.entry e ON e.id = b.entryFk
+ INNER JOIN vn.travel tr ON tr.id = e.travelFk
+ INNER JOIN vn.volumeConfig vc
+ INNER JOIN vn.item i ON i.id = b.itemFk
+ INNER JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE e.id = vEntryFk
+ GROUP BY Temp;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -54503,139 +54992,139 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
-CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_new`(
- vSerial VARCHAR(255),
- vInvoiceDate DATETIME,
- vTaxArea VARCHAR(25),
+CREATE DEFINER=`root`@`%` PROCEDURE `invoiceOut_new`(
+ vSerial VARCHAR(255),
+ vInvoiceDate DATETIME,
+ vTaxArea VARCHAR(25),
OUT vNewInvoiceId INT)
-BEGIN
-
-/* Creación de facturas emitidas.
-* requiere previamente tabla ticketToInvoice(id).
-*
-* @param vSerial serie a la cual se hace la factura
-* @param vInvoiceDate fecha de la factura
-* @param vTaxArea tipo de iva en relacion a la empresa y al cliente
-* @param vNewInvoiceId id de la factura que se acaba de generar
-*
-* @return vNewInvoiceId
-*/
-
- DECLARE vSpainCountryCode INT DEFAULT 1;
- DECLARE vIsAnySaleToInvoice BOOL;
- DECLARE vIsAnyServiceToInvoice BOOL;
- DECLARE vNewRef VARCHAR(255);
- DECLARE vWorker INT DEFAULT account.myUser_getId();
- DECLARE vCompany INT;
- DECLARE vClient INT;
- DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
- DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
- DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
- DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
- DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
-
- SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE());
-
- SELECT t.clientFk, t.companyFk
- INTO vClient, vCompany
- FROM ticketToInvoice tt
- JOIN ticket t ON t.id = tt.id
- LIMIT 1;
-
- -- Eliminem de ticketToInvoice els tickets que no han de ser facturats
- DELETE ti.*
- FROM ticketToInvoice ti
- JOIN ticket t ON t.id = ti.id
- JOIN client c ON c.id = t.clientFk
- WHERE YEAR(t.shipped) < 2001
- OR c.isTaxDataChecked = FALSE
- OR t.isDeleted
- OR c.hasToInvoice = FALSE;
-
- SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id
- INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice
- FROM ticketToInvoice t
- LEFT JOIN sale s ON s.ticketFk = t.id
- LEFT JOIN ticketService ts ON ts.ticketFk = t.id;
-
- IF vIsAnySaleToInvoice OR vIsAnyServiceToInvoice THEN
-
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
- INSERT INTO invoiceOut
- (
- ref,
- serial,
- issued,
- clientFk,
- dued,
- companyFk,
- cplusInvoiceType477Fk
- )
- SELECT
- 1,
- vSerial,
- vInvoiceDate,
- vClient,
- getDueDate(vInvoiceDate, dueDay),
- vCompany,
- IF(vSerial = vCorrectingSerial,
- vCplusCorrectingInvoiceTypeFk,
- IF(vSerial = vSimplifiedSerial,
- vCplusSimplifiedInvoiceTypeFk,
- vCplusStandardInvoiceTypeFk))
- FROM client
- WHERE id = vClient;
-
-
- SET vNewInvoiceId = LAST_INSERT_ID();
-
- SELECT `ref`
- INTO vNewRef
- FROM invoiceOut
- WHERE id = vNewInvoiceId;
-
- UPDATE ticket t
- JOIN ticketToInvoice ti ON ti.id = t.id
- SET t.refFk = vNewRef;
-
- DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
- CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
- SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
- FROM ticketToInvoice ti
- LEFT JOIN vn.ticketState ts ON ti.id = ts.ticket
- JOIN state s
- WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = vn.getAlert3State(ti.id);
-
- INSERT INTO vncontrol.inter(state_id,Id_Ticket,Id_Trabajador)
- SELECT * FROM tmp.updateInter;
-
-
- INSERT INTO ticketLog (action, userFk,originFk, description)
- SELECT 'UPDATE',account.userGetId(),ti.id, CONCAT('Crea factura ',vNewRef)
- FROM ticketToInvoice ti;
-
- CALL invoiceExpenceMake(vNewInvoiceId);
- CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
-
- UPDATE invoiceOut io
- JOIN (
- SELECT SUM(amount) AS total
- FROM invoiceOutExpence
- WHERE invoiceOutFk = vNewInvoiceId
- ) base
- JOIN (
- SELECT SUM(vat) AS total
- FROM invoiceOutTax
- WHERE invoiceOutFk = vNewInvoiceId
- ) vat
- SET io.amount = base.total + vat.total
- WHERE io.id = vNewInvoiceId;
-
- DROP TEMPORARY TABLE tmp.updateInter;
- END IF;
-
- DROP TEMPORARY TABLE `ticketToInvoice`;
+BEGIN
+
+/* Creación de facturas emitidas.
+* requiere previamente tabla ticketToInvoice(id).
+*
+* @param vSerial serie a la cual se hace la factura
+* @param vInvoiceDate fecha de la factura
+* @param vTaxArea tipo de iva en relacion a la empresa y al cliente
+* @param vNewInvoiceId id de la factura que se acaba de generar
+*
+* @return vNewInvoiceId
+*/
+
+ DECLARE vSpainCountryCode INT DEFAULT 1;
+ DECLARE vIsAnySaleToInvoice BOOL;
+ DECLARE vIsAnyServiceToInvoice BOOL;
+ DECLARE vNewRef VARCHAR(255);
+ DECLARE vWorker INT DEFAULT account.myUser_getId();
+ DECLARE vCompany INT;
+ DECLARE vClient INT;
+ DECLARE vCplusStandardInvoiceTypeFk INT DEFAULT 1;
+ DECLARE vCplusCorrectingInvoiceTypeFk INT DEFAULT 6;
+ DECLARE vCplusSimplifiedInvoiceTypeFk INT DEFAULT 2;
+ DECLARE vCorrectingSerial VARCHAR(1) DEFAULT 'R';
+ DECLARE vSimplifiedSerial VARCHAR(1) DEFAULT 'S';
+
+ SET vInvoiceDate = IFNULL(vInvoiceDate,CURDATE());
+
+ SELECT t.clientFk, t.companyFk
+ INTO vClient, vCompany
+ FROM ticketToInvoice tt
+ JOIN ticket t ON t.id = tt.id
+ LIMIT 1;
+
+ -- Eliminem de ticketToInvoice els tickets que no han de ser facturats
+ DELETE ti.*
+ FROM ticketToInvoice ti
+ JOIN ticket t ON t.id = ti.id
+ JOIN client c ON c.id = t.clientFk
+ WHERE YEAR(t.shipped) < 2001
+ OR c.isTaxDataChecked = FALSE
+ OR t.isDeleted
+ OR c.hasToInvoice = FALSE;
+
+ SELECT SUM(s.quantity * s.price * (100 - s.discount)/100), ts.id
+ INTO vIsAnySaleToInvoice, vIsAnyServiceToInvoice
+ FROM ticketToInvoice t
+ LEFT JOIN sale s ON s.ticketFk = t.id
+ LEFT JOIN ticketService ts ON ts.ticketFk = t.id;
+
+ IF vIsAnySaleToInvoice OR vIsAnyServiceToInvoice THEN
+
+ -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
+ -- el trigger añade el siguiente Id_Factura correspondiente a la vSerial
+ INSERT INTO invoiceOut
+ (
+ ref,
+ serial,
+ issued,
+ clientFk,
+ dued,
+ companyFk,
+ cplusInvoiceType477Fk
+ )
+ SELECT
+ 1,
+ vSerial,
+ vInvoiceDate,
+ vClient,
+ getDueDate(vInvoiceDate, dueDay),
+ vCompany,
+ IF(vSerial = vCorrectingSerial,
+ vCplusCorrectingInvoiceTypeFk,
+ IF(vSerial = vSimplifiedSerial,
+ vCplusSimplifiedInvoiceTypeFk,
+ vCplusStandardInvoiceTypeFk))
+ FROM client
+ WHERE id = vClient;
+
+
+ SET vNewInvoiceId = LAST_INSERT_ID();
+
+ SELECT `ref`
+ INTO vNewRef
+ FROM invoiceOut
+ WHERE id = vNewInvoiceId;
+
+ UPDATE ticket t
+ JOIN ticketToInvoice ti ON ti.id = t.id
+ SET t.refFk = vNewRef;
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.updateInter;
+ CREATE TEMPORARY TABLE tmp.updateInter ENGINE = MEMORY
+ SELECT s.id,ti.id ticket_id,vWorker Id_Trabajador
+ FROM ticketToInvoice ti
+ LEFT JOIN vn.ticketState ts ON ti.id = ts.ticket
+ JOIN state s
+ WHERE IFNULL(ts.alertLevel,0) < 3 and s.`code` = vn.getAlert3State(ti.id);
+
+ INSERT INTO vncontrol.inter(state_id,Id_Ticket,Id_Trabajador)
+ SELECT * FROM tmp.updateInter;
+
+
+ INSERT INTO ticketLog (action, userFk,originFk, description)
+ SELECT 'UPDATE',account.userGetId(),ti.id, CONCAT('Crea factura ',vNewRef)
+ FROM ticketToInvoice ti;
+
+ CALL invoiceExpenceMake(vNewInvoiceId);
+ CALL invoiceTaxMake(vNewInvoiceId,vTaxArea);
+
+ UPDATE invoiceOut io
+ JOIN (
+ SELECT SUM(amount) AS total
+ FROM invoiceOutExpence
+ WHERE invoiceOutFk = vNewInvoiceId
+ ) base
+ JOIN (
+ SELECT SUM(vat) AS total
+ FROM invoiceOutTax
+ WHERE invoiceOutFk = vNewInvoiceId
+ ) vat
+ SET io.amount = base.total + vat.total
+ WHERE io.id = vNewInvoiceId;
+
+ DROP TEMPORARY TABLE tmp.updateInter;
+ END IF;
+
+ DROP TEMPORARY TABLE `ticketToInvoice`;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -62254,23 +62743,23 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `saleBuy_Add`(vSaleFk INT, vBuyFk INT)
-BEGIN
-
+BEGIN
+
DECLARE isFood BOOLEAN;
-
- IF (SELECT COUNT(*)
- FROM vn.sale s
- 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
- WHERE s.id = vSaleFk
- AND ic.code = 'pets') THEN
-
- INSERT INTO vn.saleBuy (saleFk, buyFk)
- VALUES(vSaleFk, vBuyFk);
-
- END IF;
-
+
+ IF (SELECT COUNT(*)
+ FROM vn.sale s
+ 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
+ WHERE s.id = vSaleFk
+ AND ic.code = 'pets') THEN
+
+ INSERT INTO vn.saleBuy (saleFk, buyFk)
+ VALUES(vSaleFk, vBuyFk);
+
+ END IF;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -62352,77 +62841,77 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake`(IN `vTicketFk` INT, IN `vSectorFk` INT)
-BEGIN
-
- SET @rest:= CAST(0 AS DECIMAL(10,0));
- SET @saleFk := CAST(0 AS DECIMAL(10,0));
- SET @reserved := CAST(0 AS DECIMAL(10,0));
-
- UPDATE vn.itemShelving ish
- JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
- JOIN sale s ON s.id = sis.saleFk
- SET ish.visible = sis.quantity + ish.visible,
- ish.available = sis.quantity + ish.visible
- WHERE s.ticketFk = vTicketFk;
-
- DELETE sis.*
- FROM saleItemShelving sis
- JOIN sale s ON s.id = sis.saleFk
- WHERE s.ticketFk = vTicketFk;
-
- INSERT INTO saleItemShelving( saleFk,
- itemShelvingFk,
- quantity,
- ubication)
- SELECT saleFk,
- itemShelvingFk,
- CAST(Reserved as DECIMAL(10,0)) as Reserved,
- ubication
- FROM
- (SELECT saleFk,
- itemShelvingFk,
- ubication,
- @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta,
- @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved,
- @rest := @rest - @reserved,
- @saleFk := saleFk
- FROM
- ( SELECT s.id as saleFk,
- ish.created,
- ish.id as itemShelvingFk,
- ish.available,
- s.quantity,
- ish.packing,
- CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication
- FROM vn.sale s
- JOIN vn.ticket t ON t.id = s.ticketFk
- JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk
- JOIN vn.parking p ON p.sectorFk = sc.id
- JOIN vn.shelving sh ON sh.parkingFk = p.id
- JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk
- WHERE t.id = vTicketFk
- AND sc.id = vSectorFk
- AND s.quantity MOD ish.packing = 0
- AND s.quantity >= ish.packing
- ORDER BY s.id,
- sh.priority DESC,
- ish.packing DESC,
- ish.created
- ) sub
- ) sub2
- WHERE Reserved > 0;
-
- UPDATE vn.itemShelving ish
- JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
- JOIN vn.sale s ON s.id = sis.saleFk
- SET ish.available = ish.visible - sis.quantity,
- ish.visible = ish.visible - sis.quantity
- WHERE s.ticketFk = vTicketFk
- AND s.isPicked = FALSE;
-
- CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE);
-
-
+BEGIN
+
+ SET @rest:= CAST(0 AS DECIMAL(10,0));
+ SET @saleFk := CAST(0 AS DECIMAL(10,0));
+ SET @reserved := CAST(0 AS DECIMAL(10,0));
+
+ UPDATE vn.itemShelving ish
+ JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
+ JOIN sale s ON s.id = sis.saleFk
+ SET ish.visible = sis.quantity + ish.visible,
+ ish.available = sis.quantity + ish.visible
+ WHERE s.ticketFk = vTicketFk;
+
+ DELETE sis.*
+ FROM saleItemShelving sis
+ JOIN sale s ON s.id = sis.saleFk
+ WHERE s.ticketFk = vTicketFk;
+
+ INSERT INTO saleItemShelving( saleFk,
+ itemShelvingFk,
+ quantity,
+ ubication)
+ SELECT saleFk,
+ itemShelvingFk,
+ CAST(Reserved as DECIMAL(10,0)) as Reserved,
+ ubication
+ FROM
+ (SELECT saleFk,
+ itemShelvingFk,
+ ubication,
+ @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta,
+ @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved,
+ @rest := @rest - @reserved,
+ @saleFk := saleFk
+ FROM
+ ( SELECT s.id as saleFk,
+ ish.created,
+ ish.id as itemShelvingFk,
+ ish.available,
+ s.quantity,
+ ish.packing,
+ CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication
+ FROM vn.sale s
+ JOIN vn.ticket t ON t.id = s.ticketFk
+ JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk
+ JOIN vn.parking p ON p.sectorFk = sc.id
+ JOIN vn.shelving sh ON sh.parkingFk = p.id
+ JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk
+ WHERE t.id = vTicketFk
+ AND sc.id = vSectorFk
+ AND s.quantity MOD ish.packing = 0
+ AND s.quantity >= ish.packing
+ ORDER BY s.id,
+ sh.priority DESC,
+ ish.packing DESC,
+ ish.created
+ ) sub
+ ) sub2
+ WHERE Reserved > 0;
+
+ UPDATE vn.itemShelving ish
+ JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id
+ JOIN vn.sale s ON s.id = sis.saleFk
+ SET ish.available = ish.visible - sis.quantity,
+ ish.visible = ish.visible - sis.quantity
+ WHERE s.ticketFk = vTicketFk
+ AND s.isPicked = FALSE;
+
+ CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE);
+
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -63295,33 +63784,33 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `scanTreeCreate__`()
-BEGIN
- CALL nestTree(
- 'vn2008',
- 'scan',
- 'vn2008',
- 'scanTree'
- );
-
- UPDATE vn2008.scanTree st
- JOIN (
- SELECT sl.scan_id,
- MAX(sl.odbc_date) lastScanned,
- COUNT(DISTINCT t.routeFk) routeCount,
- MIN(t.routeFk) mod 1000 as minRoute,
- MAX(t.routeFk) mod 1000 as maxRoute,
- COUNT(sl.scan_line_id) as scanned
- FROM vn2008.scan_line sl
- JOIN expedition e ON e.id = sl.`code`
- JOIN ticket t ON t.id = e.ticketFk
- WHERE t.routeFk
- GROUP BY sl.scan_id
- ) rs ON rs.scan_id = st.id
- SET st.lastScanned = rs.lastScanned,
- st.routeCount = rs.routeCount,
- st.minRoute = rs.minRoute,
- st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL),
- st.scanned = rs.scanned;
+BEGIN
+ CALL nestTree(
+ 'vn2008',
+ 'scan',
+ 'vn2008',
+ 'scanTree'
+ );
+
+ UPDATE vn2008.scanTree st
+ JOIN (
+ SELECT sl.scan_id,
+ MAX(sl.odbc_date) lastScanned,
+ COUNT(DISTINCT t.routeFk) routeCount,
+ MIN(t.routeFk) mod 1000 as minRoute,
+ MAX(t.routeFk) mod 1000 as maxRoute,
+ COUNT(sl.scan_line_id) as scanned
+ FROM vn2008.scan_line sl
+ JOIN expedition e ON e.id = sl.`code`
+ JOIN ticket t ON t.id = e.ticketFk
+ WHERE t.routeFk
+ GROUP BY sl.scan_id
+ ) rs ON rs.scan_id = st.id
+ SET st.lastScanned = rs.lastScanned,
+ st.routeCount = rs.routeCount,
+ st.minRoute = rs.minRoute,
+ st.maxRoute = IF(rs.minRoute != rs.maxRoute, rs.maxRoute,NULL),
+ st.scanned = rs.scanned;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -67221,25 +67710,25 @@ DELIMITER ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` PROCEDURE `ticketManaToPromo`(vTicketFk INT)
-BEGIN
-
- DECLARE vManaComponent INT;
-
- DECLARE vPromoComponent INT;
-
- SELECT id INTO vManaComponent
- FROM vn.component c
- WHERE c.code = 'mana';
-
- SELECT id INTO vPromoComponent
- FROM vn.component c
- WHERE c.code = 'floramondoPromo';
-
- UPDATE vn.saleComponent sc
- JOIN vn.sale s ON s.id = sc.saleFk
- SET componentFk = vPromoComponent
- WHERE componentFk = vManaComponent
- AND s.ticketFk = vTicketFk;
+BEGIN
+
+ DECLARE vManaComponent INT;
+
+ DECLARE vPromoComponent INT;
+
+ SELECT id INTO vManaComponent
+ FROM vn.component c
+ WHERE c.code = 'mana';
+
+ SELECT id INTO vPromoComponent
+ FROM vn.component c
+ WHERE c.code = 'floramondoPromo';
+
+ UPDATE vn.saleComponent sc
+ JOIN vn.sale s ON s.id = sc.saleFk
+ SET componentFk = vPromoComponent
+ WHERE componentFk = vManaComponent
+ AND s.ticketFk = vTicketFk;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -69069,50 +69558,50 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` 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');
- ROLLBACK;
- 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);
- COMMIT;
-
- DELETE FROM ticketRecalc WHERE ticketFk = vTicketFk;
- END LOOP;
-
- CLOSE cCur;
- 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;
+ 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);
+ COMMIT;
+
+ DELETE FROM ticketRecalc WHERE ticketFk = vTicketFk;
+ END LOOP;
+
+ CLOSE cCur;
+ DO RELEASE_LOCK('vn.ticket_doRecalc');
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -69476,28 +69965,28 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-sysadmin`@`%` PROCEDURE `ticket_recalc`(vTicketId INT)
-BEGIN
-/**
- * Calcula y guarda el total con/sin IVA en un ticket.
- *
- * @param vTicketId Identificador del ticket
- */
-
- DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
- CREATE TEMPORARY TABLE tmp.ticket
- ENGINE = MEMORY
- SELECT vTicketId ticketFk;
-
- CALL ticketGetTotal;
-
- UPDATE ticket t
- JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
- SET t.totalWithVat = tt.total,
- t.totalWithoutVat = tt.totalWithoutVat;
-
- DROP TEMPORARY TABLE
- tmp.ticket,
- tmp.ticketTotal;
+BEGIN
+/**
+ * Calcula y guarda el total con/sin IVA en un ticket.
+ *
+ * @param vTicketId Identificador del ticket
+ */
+
+ DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
+ CREATE TEMPORARY TABLE tmp.ticket
+ ENGINE = MEMORY
+ SELECT vTicketId ticketFk;
+
+ CALL ticketGetTotal;
+
+ UPDATE ticket t
+ JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
+ SET t.totalWithVat = tt.total,
+ t.totalWithoutVat = tt.totalWithoutVat;
+
+ DROP TEMPORARY TABLE
+ tmp.ticket,
+ tmp.ticketTotal;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -69784,17 +70273,17 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_requestRecalc`(vSelf INT)
-proc: BEGIN
-/**
- * Adds a request to recalculate the ticket total.
- *
- * @param vSelf The ticket identifier
- */
- IF vSelf IS NULL THEN
- LEAVE proc;
- END IF;
-
- INSERT IGNORE INTO ticketRecalc SET ticketFk = vSelf;
+proc: BEGIN
+/**
+ * Adds a request to recalculate the ticket total.
+ *
+ * @param vSelf The ticket identifier
+ */
+ IF vSelf IS NULL THEN
+ LEAVE proc;
+ END IF;
+
+ INSERT IGNORE INTO ticketRecalc SET ticketFk = vSelf;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -70528,32 +71017,32 @@ DELIMITER ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`z-developer`@`%` PROCEDURE `travelVolume`(vTravelFk INT)
-BEGIN
-
- SELECT w1.name AS ORI,
- w2.name AS DES,
- tr.shipped shipment,
- tr.landed landing,
- a.name Agencia,
- s.name Proveedor,
- e.id Id_Entrada,
- e.REF Referencia,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
- CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
- vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
- FROM vn.buy b
- JOIN vn.entry e ON e.id = b.entryFk
- JOIN vn.supplier s ON s.id = e.supplierFk
- JOIN vn.travel tr ON tr.id = e.travelFk
- JOIN vn.agencyMode a ON a.id = tr.agencyFk
- JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk
- JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk
- JOIN vn.volumeConfig vc
- JOIN vn.item i ON i.id = b.itemFk
- JOIN vn.itemType it ON it.id = i.typeFk
- WHERE tr.id = vTravelFk;
-
+BEGIN
+
+ SELECT w1.name AS ORI,
+ w2.name AS DES,
+ tr.shipped shipment,
+ tr.landed landing,
+ a.name Agencia,
+ s.name Proveedor,
+ e.id Id_Entrada,
+ e.REF Referencia,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.carro / 1000000 ,1) AS DECIMAL(10,2)) AS CC,
+ CAST(ROUND(SUM(GREATEST(b.stickers ,b.quantity /b.packing ) *
+ vn.item_getVolume(b.itemFk ,b.packageFk)) / vc.espai / 1000000,1) AS DECIMAL(10,2)) AS espais
+ FROM vn.buy b
+ JOIN vn.entry e ON e.id = b.entryFk
+ JOIN vn.supplier s ON s.id = e.supplierFk
+ JOIN vn.travel tr ON tr.id = e.travelFk
+ JOIN vn.agencyMode a ON a.id = tr.agencyFk
+ JOIN vn.warehouse w1 ON w1.id = tr.warehouseInFk
+ JOIN vn.warehouse w2 ON w2.id = tr.warehouseOutFk
+ JOIN vn.volumeConfig vc
+ JOIN vn.item i ON i.id = b.itemFk
+ JOIN vn.itemType it ON it.id = i.typeFk
+ WHERE tr.id = vTravelFk;
+
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@@ -77937,7 +78426,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
-/*!50001 VIEW `accounting` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `accountingTypeFk`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive` from `vn2008`.`Bancos` `b` */;
+/*!50001 VIEW `accounting` AS select `b`.`id` 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 */;
@@ -78285,11 +78774,11 @@ USE `vn`;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `vnGenus`
+-- Final view structure for view `ediGenus`
--
-/*!50001 DROP TABLE IF EXISTS `vnGenus`*/;
-/*!50001 DROP VIEW IF EXISTS `vnGenus`*/;
+/*!50001 DROP TABLE IF EXISTS `ediGenus`*/;
+/*!50001 DROP VIEW IF EXISTS `ediGenus`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -78298,17 +78787,17 @@ USE `vn`;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
-/*!50001 VIEW `vnGenus` AS select `g`.`id` AS `id`,`g`.`name` AS `latinGenusName`,`g` from `vn`.`genus` `g` */;
+/*!50001 VIEW `ediGenus` AS select `g`.`genus_id` AS `id`,`g`.`latin_genus_name` AS `latinGenusName`,`g`.`entry_date` AS `entried`,`g`.`expiry_date` AS `dued`,`g`.`change_date_time` AS `modified` from `edi`.`genus` `g` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
--
--- Final view structure for view `vnSpecie`
+-- Final view structure for view `ediSpecie`
--
-/*!50001 DROP TABLE IF EXISTS `vnSpecie`*/;
-/*!50001 DROP VIEW IF EXISTS `vnSpecie`*/;
+/*!50001 DROP TABLE IF EXISTS `ediSpecie`*/;
+/*!50001 DROP VIEW IF EXISTS `ediSpecie`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -78317,7 +78806,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
-/*!50001 VIEW `vnSpecie` AS select `s`.`id` AS `id`,`s`.`name` AS `latinSpeciesName`,`s` from `vn`.`specie` `s` */;
+/*!50001 VIEW `ediSpecie` AS select `s`.`specie_id` AS `id`,`s`.`genus_id` AS `genusFk`,`s`.`latin_species_name` AS `latinSpeciesName`,`s`.`entry_date` AS `entried`,`s`.`expiry_date` AS `dued`,`s`.`change_date_time` AS `modified` from `edi`.`specie` `s` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -78849,7 +79338,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb4_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */
-/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,ifnull(`ib`.`botanical`,concat(`g`.`latinGenusName`,' ',ifnull(`s`.`latinSpeciesName`,''))) AS `ediBotanic` from ((`vn`.`itemBotanical` `ib` left join `vn`.`vnGenus` `g` on(`g`.`id` = `ib`.`genusFk`)) left join `vn`.`vnSpecie` `s` on(`s`.`id` = `ib`.`specieFk`)) */;
+/*!50001 VIEW `itemBotanicalWithGenus` AS select `ib`.`itemFk` AS `itemFk`,ifnull(`ib`.`botanical`,concat(`g`.`latinGenusName`,' ',ifnull(`s`.`latinSpeciesName`,''))) AS `ediBotanic` from ((`vn`.`itemBotanical` `ib` left join `vn`.`ediGenus` `g` on(`g`.`id` = `ib`.`genusFk`)) left join `vn`.`ediSpecie` `s` on(`s`.`id` = `ib`.`specieFk`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -80237,4 +80726,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2021-03-02 7:45:42
+-- Dump completed on 2021-03-04 8:02:58
diff --git a/e2e/paths/12-entry/06_observations.spec.js b/e2e/paths/12-entry/06_observations.spec.js
index 3cb8129ec..107c2e0b6 100644
--- a/e2e/paths/12-entry/06_observations.spec.js
+++ b/e2e/paths/12-entry/06_observations.spec.js
@@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
-fdescribe('Entry observations path', () => {
+describe('Entry observations path', () => {
let browser;
let page;