From c8b156771d39f9893ca84093f547464f60adcd1b Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 9 Feb 2024 14:00:16 +0100 Subject: [PATCH 01/42] feat: refs #6395 Added buyerFk in buy --- db/routines/vn/triggers/buy_beforeInsert.sql | 1 + db/routines/vn/triggers/buy_beforeUpdate.sql | 4 ++++ db/versions/10880-salmonHydrangea/00-firstScript.sql | 1 + 3 files changed, 6 insertions(+) create mode 100644 db/versions/10880-salmonHydrangea/00-firstScript.sql diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index c88bef05a..c698e23e6 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -19,6 +19,7 @@ trig: BEGIN END IF; SET NEW.editorFk = account.myUser_getId(); + SET NEW.buyerFk = NEW.editorFk; CALL buy_checkGrouping(NEW.`grouping`); diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index fc03c456f..b41418bcc 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -65,6 +65,10 @@ trig:BEGIN SET NEW.isIgnored = TRUE; END IF; + IF NOT (NEW.itemFk <=> OLD.itemFk) THEN + SET NEW.buyerFk = NEW.editorFk; + END IF; + IF NOT (NEW.itemFk <=> OLD.itemFk) OR NOT (OLD.entryFk <=> NEW.entryFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck diff --git a/db/versions/10880-salmonHydrangea/00-firstScript.sql b/db/versions/10880-salmonHydrangea/00-firstScript.sql new file mode 100644 index 000000000..934fc2020 --- /dev/null +++ b/db/versions/10880-salmonHydrangea/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.buy ADD buyerFk int(10) unsigned DEFAULT NULL NULL; From 0eaeb2e80598c4bfc77e01cd1abdbe904d2e545f Mon Sep 17 00:00:00 2001 From: pako Date: Thu, 15 Feb 2024 13:13:22 +0100 Subject: [PATCH 02/42] nueva rama --- db/dump/fixtures.after.sql | 404 ++++++++++++++++++ db/routines/floranet/events/clean.sql | 22 + .../floranet/procedures/catalogue_get.sql | 52 +++ .../floranet/procedures/order_confirm.sql | 25 ++ db/routines/floranet/procedures/order_put.sql | 42 ++ .../10887-floranet/00-schemaAndUser.sql | 14 + db/versions/10887-floranet/01-tables.sql | 61 +++ 7 files changed, 620 insertions(+) create mode 100644 db/routines/floranet/events/clean.sql create mode 100644 db/routines/floranet/procedures/catalogue_get.sql create mode 100644 db/routines/floranet/procedures/order_confirm.sql create mode 100644 db/routines/floranet/procedures/order_put.sql create mode 100644 db/versions/10887-floranet/00-schemaAndUser.sql create mode 100644 db/versions/10887-floranet/01-tables.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 4c5f89d97..a7d059ed2 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -292,7 +292,411 @@ INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount */ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); +-- XXX: floranet +INSERT INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + +-- Generación de items +SELECT id + INTO @FNR + FROM vn.itemType + WHERE code = 'FNR'; + +SELECT id + INTO @FNP + FROM vn.itemType + WHERE code = 'FNP'; + +DELETE + FROM vn.item + WHERE typeFk IN (@FNR,@FNP); + +SELECT MAX(id) + 1 + INTO @item + FROM vn.item; + +INSERT INTO vn.item + ( + id, + name, + longName, + `size`, + originFk, + intrastatFk, + typeFk, + inkFk, + image, + description + ) + VALUES + ( + @item := @item + 1, + @r := 'Ramo Terranova', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1CwtEK5_GReAzconaJsPTCXxV7zajbTos/view?usp=drive_link', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', + 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', + 'paniculata eucaliptus.') + ), + ( + @item := @item + 1, + @r := 'Ramo Tasmania', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1_149uYZ-sehw3vWH68Quttk8QJe5T_bG/view?usp=drive_link', + CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', + 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', + 'flores será un acierto seguro para hacer un regalo muy especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Pasion', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1-dH1UilV-nOH9XNK23uooZoezlwMT-Jq/view?usp=drive_link', + CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', + 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', + 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', + 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', + 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') + ), + ( + @item := @item + 1, + @r := 'Ramo Florencia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1PWKo5N8kg8H3xQtELdeQTQIc1HMZCc1P/view?usp=drive_link', + CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', + 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', + 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', + 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Atardecer', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink WHERE name = 'Yellow'), + 'https://drive.google.com/file/d/1eM4gtftQuXN5xUjAHIRUYNPZNmuHVRA_/view?usp=drive_link', + CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', + 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', + 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', + 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', + 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') + ), + ( + @item := @item + 1, + @r := 'Ramo Arcoíris', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1Hxk5yqo7891gfK1VKIYfWxO5a_0K2Qej/view?usp=drive_link', + CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', + 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', + 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', + 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', + 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', + 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') + ), + ( + @item := @item + 1, + @r := 'Ramo Provenza', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1TA9SBwjqnrEqG1bzwDL37sxtX9CNyLJk/view?usp=drive_link', + CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', + 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', + 'con una selección de maravillosos verdes variados, hacen que esta combinación ', + 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') + ), + ( + @item := @item + 1, + @r := 'Ramo Alegria', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1sOf2isj84P9OxR3E3x6n2PjPnWVamLCE/view?usp=drive_link', + CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', + 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', + ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', + 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', + 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') + ), + ( + @item := @item + 1, + @r := 'Planta Orquídeas ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/14BIkDDonFaIiTyJer1CWju1YzZNzt3XQ/view?usp=drive_link', + CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', + 'con las mejores características combinadas con diferentes elementos de ', + 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', + 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', + 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', + 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') + ), + ( + @item := @item + 1, + @r := 'Planta Kentia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1rKe2RicfWha-VIm1LbbXckbA41glA99K/view?usp=drive_link', + CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', + 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', + 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', + 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', + 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', + 'de ser un producto nacional producido en Canarias de una calidad extrema.') + ), + ( + @item := @item + 1, + @r := 'Planta Calathea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/11CKm5rqVFVPOELciuyXUrkc2oeTHJzBE/view?usp=drive_link', + CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', + ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', + 'llamativo y original colorido, tambien es un regalo perfecto para ', + 'cualquier compromiso que tengamos .') + ), + ( + @item := @item + 1, + @r := 'Planta Anthurium ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink WHERE name = 'Red'), + 'https://drive.google.com/file/d/1j4il_N9VJGaP4f6CPZM0u6GjxwIeYcBt/view?usp=drive_link', + CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', + 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', + 'su llamativo color alegrará cualquier celebración') + ), + ( + @item := @item + 1, + @r := 'Ramo Mindanao', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1lsGDuC6xmv3SyGukfLTVYsQvbGf1Bzxy/view?usp=drive_link', + CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', + 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', + 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') + ), + ( + @item := @item + 1, + @r := 'Ramo Guinea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1MtF0oghv-ahogaAaVpJNzDiIfyeCCmAi/view?usp=drive_link', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', + ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') + ), + ( + @item := @item + 1, + @r := 'Ramo Eterno', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/1AOMqlZAKqImnnWSmeq1DW1Krj78mACCG/view?usp=drive_link', + CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', + 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', + 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', + 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', + 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', + 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') + ), + ( + @item := @item + 1, + @r := 'Ramo Cielo', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + 'https://drive.google.com/file/d/168DikIOwVT5OO4BHARBoWwLB1wjpAS7s/view?usp=drive_link', + CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', + 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', + ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', + 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', + ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', + 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', + 'clara de todo el conjunto. ') + ); + + -- Ramo Terranova: 1er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Rosa roja', + @r, + 60, + 1, + 'RED', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 12 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + -- Ramo Terranova: 2º elemento + +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Hoja de helecho', + @r, + 60, + 1, + 'BAS', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 4 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- Ramo Terranova: 3er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Paniculata', + @r, + 60, + 1, + 'SLV', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 5 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- XXX SET foreign_key_checks = 1; diff --git a/db/routines/floranet/events/clean.sql b/db/routines/floranet/events/clean.sql new file mode 100644 index 000000000..4477112fd --- /dev/null +++ b/db/routines/floranet/events/clean.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE + DEFINER=`root`@`localhost` + EVENT `floranet`.`clean` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-01-01 23:00:00.000' + ON COMPLETION PRESERVE + ENABLE +DO +BEGIN + DELETE + FROM `order` + WHERE created < CURDATE() + AND isPaid = FALSE; + + DELETE c.* + FROM catalogue c + LEFT JOIN `order` o ON o.catalogueFk = c.id + WHERE c.created < CURDATE() + AND o.id IS NULL; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql new file mode 100644 index 000000000..914b5d27f --- /dev/null +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -0,0 +1,52 @@ +DROP PROCEDURE IF EXISTS floranet.catalogue_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) +READS SQL DATA +BEGIN +/** + * Returns list, price and all the stuff regarding the floranet items + * + * @param vLanded Delivery date + * @param vPostalCode Delivery address postal code + */ + DECLARE vLastCatalogueFk INT; + + START TRANSACTION; + + SELECT * FROM catalogue FOR UPDATE; + + SELECT MAX(id) INTO vLastCatalogueFk + FROM catalogue; + + INSERT INTO catalogue( + name, + price, + itemFk, + dated, + postalCode, + `type`, + image, + description + ) + SELECT i.name, + i.`size`, + i.id, + vLanded, + vPostalCode, + it.name, + i.image, + i.description + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP'); + + SELECT * + FROM catalogue + WHERE id > IFNULL(vLastCatalogueFk,0); + + COMMIT; + +END$$ +DELIMITER ; diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql new file mode 100644 index 000000000..fed123663 --- /dev/null +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -0,0 +1,25 @@ +DROP PROCEDURE IF EXISTS floranet.order_confirm; + +DELIMITER $$ +$$ + +CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) +READS SQL DATA + +BEGIN +/** Update order.isPaid field + * + * @param vCatalogueFk floranet.catalogue.id + * + * @returns floranet.order.isPaid + */ + UPDATE `order` + SET isPaid = TRUE, + payed = NOW() + WHERE catalogueFk = vCatalogueFk; + + SELECT isPaid + FROM `order` + WHERE catalogueFk = vCatalogueFk; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql new file mode 100644 index 000000000..c26cef19a --- /dev/null +++ b/db/routines/floranet/procedures/order_put.sql @@ -0,0 +1,42 @@ +DROP PROCEDURE IF EXISTS floranet.order_put; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) +READS SQL DATA +BEGIN +/** + * Get and process an order + * + * @param vOrder Data of the order + * + * Customer data: , , + * + * Item data: , + * + * Delivery data: ,
, + * + */ + INSERT IGNORE INTO `order`( + catalogueFk, + customerName, + email, + customerPhone, + message, + deliveryName, + address, + deliveryPhone + ) + VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')), + JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone')) + ); + + SELECT LAST_INSERT_ID() orderFk; +END$$ +DELIMITER ; diff --git a/db/versions/10887-floranet/00-schemaAndUser.sql b/db/versions/10887-floranet/00-schemaAndUser.sql new file mode 100644 index 000000000..34da92550 --- /dev/null +++ b/db/versions/10887-floranet/00-schemaAndUser.sql @@ -0,0 +1,14 @@ + +CREATE SCHEMA IF NOT EXISTS `floranet`; + +CREATE ROLE IF NOT EXISTS 'floranet' ; + +GRANT Create temporary tables ON floranet.* TO 'floranet'; + +GRANT Execute ON floranet.* TO 'floranet'; + +GRANT Lock tables ON floranet.* TO 'floranet'; + +CREATE USER IF NOT EXISTS 'floranet'@'%'; + +GRANT floranet TO floranet@'%'; \ No newline at end of file diff --git a/db/versions/10887-floranet/01-tables.sql b/db/versions/10887-floranet/01-tables.sql new file mode 100644 index 000000000..b63c81c21 --- /dev/null +++ b/db/versions/10887-floranet/01-tables.sql @@ -0,0 +1,61 @@ +CREATE OR REPLACE TABLE floranet.`builder` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(11) NOT NULL, + `elementFk` int(11) NOT NULL, + `quantity` int(10) unsigned NOT NULL DEFAULT 1, + PRIMARY KEY (`id`), + KEY `builder_FK` (`itemFk`), + KEY `builder_FK_1` (`elementFk`), + CONSTRAINT `builder_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements'; + +CREATE OR REPLACE TABLE floranet.`element` ( + `itemFk` int(11) NOT NULL, + `typeFk` smallint(5) unsigned DEFAULT NULL, + `size` int(11) DEFAULT NULL, + `inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `name` varchar(30) DEFAULT NULL, + `quantity` int(11) NOT NULL DEFAULT 1, + PRIMARY KEY (`itemFk`), + KEY `element_FK` (`itemFk`), + KEY `element_FK_1` (`typeFk`), + KEY `element_FK_2` (`inkFk`), + KEY `element_FK_3` (`originFk`), + CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción'; + +ALTER TABLE floranet.builder ADD CONSTRAINT `builder_FK_1` FOREIGN KEY (`elementFk`) REFERENCES `element` (`itemFk`) ON UPDATE CASCADE; + +CREATE OR REPLACE TABLE floranet.catalogue +(id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50), + price DECIMAL(10,2) NOT NULL, + itemFk INT NOT NULL, + dated DATE, + postalCode VARCHAR(12), + `type` VARCHAR(50), + image VARCHAR(255), + description TEXT, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + payed DATETIME, + FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE); + + +CREATE OR REPLACE TABLE floranet.`order` +(id INT AUTO_INCREMENT PRIMARY KEY, + catalogueFk INT UNIQUE, + customerName VARCHAR(100), + email VARCHAR(100), + customerPhone VARCHAR(15), + message VARCHAR(255), + deliveryName VARCHAR(100), + address VARCHAR(200), + deliveryPhone VARCHAR(100), + isPaid BOOL NOT NULL DEFAULT FALSE, + payed DATETIME, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (catalogueFk) REFERENCES catalogue(id) ON DELETE RESTRICT ON UPDATE CASCADE); \ No newline at end of file From 04df5a0ccdf4b1864adf7c1003decbaa54cd1ca4 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 13:52:58 +0100 Subject: [PATCH 03/42] refs #6021 --- db/routines/vn/views/zoneEstimatedDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql index 90c7381d8..c50d3602b 100644 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`zoneClosure` `zc` ON( `zc`.`zoneFk` = `t`.`zoneFk` - AND `zc`.`dated` = `util`.`VN_CURDATE`() + AND `zc`.`dated` = `util`.`VN_CURDATE`() ) ) LEFT JOIN `cache`.`departure_limit` `dl` ON( From ec9604323dbb0eef440071b57038ecf88186f050 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 13:54:34 +0100 Subject: [PATCH 04/42] commit --- db/routines/vn/views/zoneEstimatedDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/zoneEstimatedDelivery.sql b/db/routines/vn/views/zoneEstimatedDelivery.sql index c50d3602b..90c7381d8 100644 --- a/db/routines/vn/views/zoneEstimatedDelivery.sql +++ b/db/routines/vn/views/zoneEstimatedDelivery.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`zoneClosure` `zc` ON( `zc`.`zoneFk` = `t`.`zoneFk` - AND `zc`.`dated` = `util`.`VN_CURDATE`() + AND `zc`.`dated` = `util`.`VN_CURDATE`() ) ) LEFT JOIN `cache`.`departure_limit` `dl` ON( From 74136442954aba00717704dedf56b801aba02817 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 14:37:09 +0100 Subject: [PATCH 05/42] contact_request and deliveryDate_get --- .../floranet/procedures/contact_Request.sql | 20 +++++++++++ .../floranet/procedures/deliveryDate_get.sql | 35 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 db/routines/floranet/procedures/contact_Request.sql create mode 100644 db/routines/floranet/procedures/deliveryDate_get.sql diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_Request.sql new file mode 100644 index 000000000..c55348d6f --- /dev/null +++ b/db/routines/floranet/procedures/contact_Request.sql @@ -0,0 +1,20 @@ +DROP PROCEDURE IF EXISTS floranet.contact_Request; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` +PROCEDURE floranet.contact_Request( + vName VARCHAR(100), + vPhone VARCHAR(15), + vEmail VARCHAR(100), + vMessage TEXT) +READS SQL DATA +BEGIN +/** + * Set actions for contact request + * + * @param vPostalCode Delivery address postal code + */ + +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql new file mode 100644 index 000000000..06a8ae1ad --- /dev/null +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -0,0 +1,35 @@ +DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.deliveryDate_get(vPostalCode VARCHAR(15)) +READS SQL DATA +BEGIN +/** + * Returns available dates for this postalCode + * + * @param vPostalCode Delivery address postal code + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.deliveryDate + (dated DATE PRIMARY KEY) + ENGINE = MEMORY; + + IF vPostalCode != "00000" THEN + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 1 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 2 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 4 DAY; + + INSERT INTO tmp.deliveryDate + SET dated = CURDATE() + INTERVAL 7 DAY; + END IF; + + SELECT * FROM tmp.deliveryDate; + + DROP TEMPORARY TABLE tmp.deliveryDate; +END$$ +DELIMITER ; \ No newline at end of file From 24b564f1ce559382d3386b041471110e1d0b6544 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 15 Feb 2024 14:42:06 +0100 Subject: [PATCH 06/42] test --- db/routines/floranet/procedures/contact_Request.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_Request.sql index c55348d6f..7673c2203 100644 --- a/db/routines/floranet/procedures/contact_Request.sql +++ b/db/routines/floranet/procedures/contact_Request.sql @@ -11,7 +11,7 @@ PROCEDURE floranet.contact_Request( READS SQL DATA BEGIN /** - * Set actions for contact request + * Set actions for contact request. * * @param vPostalCode Delivery address postal code */ From 2f275d8f32bc9451c8a225e8cc5e3fb853a98f58 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 29 Feb 2024 13:06:26 +0100 Subject: [PATCH 07/42] itemType add --- db/dump/fixtures.after.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index a7d059ed2..13e423d68 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -294,8 +294,15 @@ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); -- XXX: floranet -INSERT INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); +INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNR', 'Floranet Ramos', 1, 1); + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNP', 'Floranet Plantas', 1, 1); -- Generación de items SELECT id From 1ccec1e0fb5ab8d5b747431693a5ce49860e7a73 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 4 Mar 2024 08:11:06 +0100 Subject: [PATCH 08/42] refs #6499 procRefactor part 6 --- .../procedures/absoluteInventoryHistory.sql | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 db/routines/vn/procedures/absoluteInventoryHistory.sql diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql new file mode 100644 index 000000000..427b9ba51 --- /dev/null +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -0,0 +1,99 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( + vIdArticle INT, vWarehouse INT, vDate DATETIME) +BEGIN +/** +* Calcula y proporciona un historial de inventario absoluto +* para un artículo específico en un almacén dado +* hasta una fecha determinada. +* +* @param vIdArticle Id de artículo +* @param vWarehouse Almacén +* @param vDate Fecha +*/ + DECLARE vCalculatedInventory INT; + DECLARE vToday DATETIME; + + SET vToday = util.VN_CURDATE(); + + CREATE OR REPLACE TEMPORARY TABLE historicalPast + ENGINE = MEMORY + SELECT * + FROM ( + SELECT tr.landed Fecha, + b.quantity Entrada, + NULL Salida, + (tr.isReceived != FALSE) OK, + s.name Alias, + e.invoiceNumber Referencia, + e.id id, + tr.isDelivered F5 + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + WHERE tr.landed >= '2001-01-01' + AND s.id <> 4 + AND vWarehouse IN (tr.warehouseInFk, 0) + AND b.itemFk = vIdArticle + AND e.isExcludedFromAvailable = 0 + AND e.isRaid = 0 + UNION ALL + SELECT tr.shipped Fecha, + NULL Entrada, + b.quantity Salida, + tr.isDelivered OK, + s.name Alias, + e.invoiceNumber Referencia, + e.id id, + tr.isDelivered F5 + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN supplier s ON s.id = e.supplierFk + WHERE tr.shipped >= '2001-01-01' + AND vWarehouse = tr.warehouseOutFk + AND s.id <> 4 + AND b.itemFk = vIdArticle + AND e.isExcludedFromAvailable = 0 + AND e.isRaid = 0 + UNION ALL + SELECT t.shipped Fecha, + NULL Entrada, + m.quantity Salida, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, + t.nickname Alias, + t.refFk Referencia, + t.id, + t.isPrinted + FROM sale m + JOIN Tickets T USING (Id_Ticket) + JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente + WHERE T.Fecha >= '2001-01-01' + AND M.Id_Article = vIdArticle + AND vWarehouse IN (T.warehouse_id , 0) + ) t1 + ORDER BY Fecha, Entrada DESC, OK DESC; + + SELECT sum(Entrada) - sum(Salida) INTO vCalculatedInventory + FROM historicalPast + WHERE Fecha < vDate; + + SELECT p1.*, NULL v_virtual + FROM( + SELECT vDate Fecha, + vCalculatedInventory Entrada, + NULL Salida, + 1 OK, + 'Inventario calculado' Alias, + '' Referencia, 0 id, + 1 F5 + UNION ALL + SELECT * + FROM historicalPast + WHERE Fecha >= vDate + ) p1; + + DROP TEMPORARY TABLE historicalPast; +END$$ +DELIMITER ; \ No newline at end of file From 68846d30184961cd92704a65c95617b58876ee40 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 5 Mar 2024 13:43:03 +0100 Subject: [PATCH 09/42] refs #6499 Refactor historico_multiple --- .../procedures/absoluteInventoryHistory.sql | 109 ++++++------ .../procedures/multipleInventoryHistory.sql | 161 ++++++++++++++++++ 2 files changed, 216 insertions(+), 54 deletions(-) create mode 100644 db/routines/vn/procedures/multipleInventoryHistory.sql diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 427b9ba51..f1a317598 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vIdArticle INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, vWarehouse INT, vDate DATETIME) BEGIN /** * Calcula y proporciona un historial de inventario absoluto * para un artículo específico en un almacén dado * hasta una fecha determinada. * -* @param vIdArticle Id de artículo +* @param vItemFk Id de artículo * @param vWarehouse Almacén * @param vDate Fecha */ @@ -16,84 +16,85 @@ BEGIN SET vToday = util.VN_CURDATE(); - CREATE OR REPLACE TEMPORARY TABLE historicalPast - ENGINE = MEMORY + CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast + ENGINE = MEMORY SELECT * FROM ( - SELECT tr.landed Fecha, - b.quantity Entrada, - NULL Salida, - (tr.isReceived != FALSE) OK, - s.name Alias, - e.invoiceNumber Referencia, + SELECT tr.landed `date`, + b.quantity input, + NULL `output`, + (tr.isReceived != FALSE) ok, + s.name alias, + e.invoiceNumber reference, e.id id, - tr.isDelivered F5 + tr.isDelivered f5 FROM buy b - JOIN entry e ON e.id = b.entryFk + JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk + JOIN supplier s ON s.id = e.supplierFk WHERE tr.landed >= '2001-01-01' AND s.id <> 4 AND vWarehouse IN (tr.warehouseInFk, 0) - AND b.itemFk = vIdArticle - AND e.isExcludedFromAvailable = 0 - AND e.isRaid = 0 + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid UNION ALL - SELECT tr.shipped Fecha, - NULL Entrada, - b.quantity Salida, - tr.isDelivered OK, - s.name Alias, - e.invoiceNumber Referencia, + SELECT tr.shipped `date`, + NULL input, + b.quantity `output`, + tr.isDelivered ok, + s.name alias, + e.invoiceNumber reference, e.id id, - tr.isDelivered F5 + tr.isDelivered f5 FROM buy b - JOIN entry e ON e.id = b.entryFk + JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk + JOIN supplier s ON s.id = e.supplierFk WHERE tr.shipped >= '2001-01-01' AND vWarehouse = tr.warehouseOutFk AND s.id <> 4 - AND b.itemFk = vIdArticle - AND e.isExcludedFromAvailable = 0 - AND e.isRaid = 0 + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid UNION ALL - SELECT t.shipped Fecha, - NULL Entrada, - m.quantity Salida, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, - t.nickname Alias, - t.refFk Referencia, + SELECT t.shipped `date`, + NULL input, + m.quantity `output`, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + t.nickname alias, + t.refFk reference, t.id, t.isPrinted FROM sale m - JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' - AND M.Id_Article = vIdArticle - AND vWarehouse IN (T.warehouse_id , 0) + JOIN ticket t ON t.id = m.ticketFk + JOIN client c ON c.id = t.clientFk + WHERE t.shipped >= '2001-01-01' + AND m.itemFk = vItemFk + AND vWarehouse IN (t.warehouseFk , 0) ) t1 - ORDER BY Fecha, Entrada DESC, OK DESC; + ORDER BY `date`, input DESC, ok DESC; - SELECT sum(Entrada) - sum(Salida) INTO vCalculatedInventory - FROM historicalPast - WHERE Fecha < vDate; + SELECT sum(input) - sum(`output`) INTO vCalculatedInventory + FROM tHistoricalPast + WHERE `date` < vDate; SELECT p1.*, NULL v_virtual FROM( - SELECT vDate Fecha, - vCalculatedInventory Entrada, - NULL Salida, - 1 OK, - 'Inventario calculado' Alias, - '' Referencia, 0 id, - 1 F5 + SELECT vDate `date`, + vCalculatedInventory input, + NULL `output`, + 1 ok, + 'Inventario calculado' alias, + '' reference, + 0 id, + 1 f5 UNION ALL - SELECT * - FROM historicalPast - WHERE Fecha >= vDate + SELECT * + FROM tHistoricalPast + WHERE `date` >= vDate ) p1; - DROP TEMPORARY TABLE historicalPast; + DROP TEMPORARY TABLE tHistoricalPast; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql new file mode 100644 index 000000000..bd399e889 --- /dev/null +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -0,0 +1,161 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( + vItemFk INT) +BEGIN +/** +* Calcula y proporciona un historial de inventario detallado +* para un artículo dividiendo la información +* por almacén. +* +* @param vItemFk Artículo +*/ + DECLARE vDateInventory DATETIME; + + SELECT inventoried INTO vDateInventory FROM config; + + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1; + + CREATE TEMPORARY TABLE tMultipleHistory1 + SELECT DATE(`date`) `date`, + input, + `output`, + ok, + reference, + history.id, + warehouse, + `name` warehouseName + FROM ( + SELECT tr.landed `date`, + c.quantity input, + NULL `output`, + IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, + (tr.isReceived <> FALSE) ok, + e.invoiceNumber reference, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT tr.shipped `date`, + NULL input, + c.quantity `output`, + warehouseOutFk warehouse, + tr.isDelivered ok, + e.invoiceNumber reference, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.shipped >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT t.shipped `date`, + NULL input, + m.quantity `output`, + warehouseInFk warehouse, + (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + t.refFk reference, + t.id id + FROM sale m + JOIN ticket t ON t.id = m.ticketFk + WHERE t.shipped >= vDateInventory + AND m.itemFk = vItemFk + ) history + JOIN warehouse ON warehouse.id = history.warehouse + ORDER BY `date`, input DESC, ok DESC; + + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory4; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory5; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory6; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory7; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory8; + CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; + CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; + CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; + CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5; + CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17; + CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37; + CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; + + SELECT * + FROM ( + SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, + NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, + NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, + NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, + NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, + NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, + NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid + FROM tMultipleHistory2 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory3 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory4 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory5 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory6 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory7 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id + FROM tMultipleHistory8 + ) sub + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; +END$$ +DELIMITER ; \ No newline at end of file From f215ce5f05e4812a477fd1d6c3bf1d602c447275 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 5 Mar 2024 14:33:16 +0100 Subject: [PATCH 10/42] refs #6498 Delete procedures vn2008 and grant vn procs --- .../vn2008/procedures/historico_absoluto.sql | 91 -------- .../vn2008/procedures/historico_multiple.sql | 206 ------------------ .../10932-azureEucalyptus/00-firstScript.sql | 2 + 3 files changed, 2 insertions(+), 297 deletions(-) delete mode 100644 db/routines/vn2008/procedures/historico_absoluto.sql delete mode 100644 db/routines/vn2008/procedures/historico_multiple.sql create mode 100644 db/versions/10932-azureEucalyptus/00-firstScript.sql diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql deleted file mode 100644 index 1a7e1dbfa..000000000 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ /dev/null @@ -1,91 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME) -BEGIN - - DECLARE inv_calculado INT; - DECLARE inv INT; - DECLARE today DATETIME; - DECLARE fecha_inv DATETIME; - - SET today = util.VN_CURDATE(); - - CREATE OR REPLACE TEMPORARY TABLE historico_pasado - SELECT * - FROM ( - SELECT TR.landing Fecha, - C.Cantidad Entrada, - NULL Salida, - (TR.received != FALSE) OK, - P.Proveedor Alias, - E.Referencia Referencia, - E.Id_Entrada id, - TR.delivered F5 - FROM Compres C -- mirar perque no entra en received - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) - WHERE TR.landing >= '2001-01-01' - AND Id_proveedor <> 4 - AND wh IN (TR.warehouse_id , 0) - AND C.Id_Article = idART - AND E.Inventario = 0 - AND E.Redada = 0 - UNION ALL - SELECT TR.shipment Fecha, - NULL Entrada, - C.Cantidad Salida, - TR.delivered OK, - P.Proveedor Alias, - E.Referencia Referencia, - E.Id_Entrada id, - TR.delivered F5 - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - INNER JOIN Proveedores P USING (Id_Proveedor) - WHERE TR.shipment >= '2001-01-01' - AND wh = TR.warehouse_id_out - AND Id_Proveedor <> 4 - AND C.Id_Article = idART - AND E.Inventario = 0 - AND E.Redada = 0 - UNION ALL - SELECT T.Fecha Fecha, - NULL Entrada, - M.Cantidad Salida, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK, - T.Alias Alias, - T.Factura Referencia, - T.Id_Ticket, - T.PedidoImpreso - FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' - AND M.Id_Article = idART - AND wh IN (T.warehouse_id , 0) - ) t1 - ORDER BY Fecha, Entrada DESC, OK DESC; - - SELECT sum(Entrada) - sum(Salida) INTO inv_calculado - FROM historico_pasado - WHERE Fecha < datfecha; - - SELECT p1.*, NULL v_virtual - FROM( - SELECT datfecha Fecha, - inv_calculado Entrada, - NULL Salida, - 1 OK, - 'Inventario calculado' Alias, - '' Referencia, 0 id, - 1 F5 - UNION ALL - SELECT * - FROM historico_pasado - WHERE Fecha >= datfecha - ) p1; - - DROP TEMPORARY TABLE historico_pasado; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql deleted file mode 100644 index ae4045a34..000000000 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ /dev/null @@ -1,206 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_multiple`(IN vItemFk INT) -BEGIN - - DECLARE vDateInventory DATETIME; - - SELECT Fechainventario INTO vDateInventory FROM tblContadores; - - SET @a = 0; - - DROP TEMPORARY TABLE IF EXISTS hm1; - - CREATE TEMPORARY TABLE hm1 - SELECT DATE(Fecha) as Fecha, - Entrada, - Salida, - OK, - Referencia, - Historia.id, - - wh, - - `name` as wh_name - - FROM - - ( SELECT TR.landing as Fecha, - C.Cantidad as Entrada, - NULL as Salida, - - IF(warehouse_id = 44, 1, warehouse_id) as wh, - (TR.received != FALSE) as OK, - E.Referencia as Referencia, - E.Id_Entrada as id - - - - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - WHERE TR.landing >= vDateInventory - AND C.Id_Article = vItemFk - AND E.Redada = 0 - - AND C.Cantidad <> 0 - - UNION ALL - - SELECT TR.shipment as Fecha, - NULL as Entrada, - C.Cantidad as Salida, - warehouse_id_out as wh, - TR.delivered as OK, - E.Referencia as Referencia, - E.Id_Entrada as id - - FROM Compres C - INNER JOIN Entradas E USING (Id_Entrada) - INNER JOIN travel TR ON TR.id = E.travel_id - WHERE TR.shipment >= vDateInventory - AND C.Id_Article = vItemFk - - AND E.Redada = 0 - - AND C.Cantidad <> 0 - - UNION ALL - - SELECT T.Fecha as Fecha, - NULL as Entrada, - M.Cantidad as Salida, - warehouse_id as wh, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, - T.Factura as Referencia, - T.Id_Ticket as id - - FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - WHERE T.Fecha >= vDateInventory - AND M.Id_Article = vItemFk - - ) AS Historia - - INNER JOIN warehouse ON warehouse.id = Historia.wh - ORDER BY Fecha, Entrada DESC, OK DESC; - - - DROP TEMPORARY TABLE IF EXISTS hm2; - DROP TEMPORARY TABLE IF EXISTS hm3; - DROP TEMPORARY TABLE IF EXISTS hm4; - DROP TEMPORARY TABLE IF EXISTS hm5; - DROP TEMPORARY TABLE IF EXISTS hm6; - DROP TEMPORARY TABLE IF EXISTS hm7; - DROP TEMPORARY TABLE IF EXISTS hm8; - CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19; - CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7; - CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60; - CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5; - CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17; - CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37; - CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55; - - SELECT * FROM - - ( - - SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid, - - NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid, - - NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid, - - NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid, - - NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid, - - NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid, - - NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid - - FROM hm2 - - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - ,Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm3 - - - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm4 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm5 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - FROM hm6 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - , NULL, NULL, NULL, NULL, NULL - - - FROM hm7 - - UNION ALL - - SELECT Fecha - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , NULL, NULL, NULL, NULL, NULL - , Entrada, Salida, OK, Referencia, id - - FROM hm8 - - ) sub - - ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL; - -END$$ -DELIMITER ; diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..55eea3211 --- /dev/null +++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql @@ -0,0 +1,2 @@ +GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer; +GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer; From 354ecfaa1684d1f17db20d092ce9821a849219d9 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 09:00:21 +0100 Subject: [PATCH 11/42] refs #6498 Arreglar grant y tabs --- .../procedures/absoluteInventoryHistory.sql | 4 +- .../procedures/multipleInventoryHistory.sql | 206 +++++++++--------- .../10932-azureEucalyptus/00-firstScript.sql | 20 ++ 3 files changed, 125 insertions(+), 105 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index f1a317598..a1e143185 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vItemFk INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, vWarehouse INT, vDate DATETIME) BEGIN /** * Calcula y proporciona un historial de inventario absoluto @@ -72,7 +72,7 @@ BEGIN WHERE t.shipped >= '2001-01-01' AND m.itemFk = vItemFk AND vWarehouse IN (t.warehouseFk , 0) - ) t1 + ) t1 ORDER BY `date`, input DESC, ok DESC; SELECT sum(input) - sum(`output`) INTO vCalculatedInventory diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index bd399e889..b15cab549 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT) + vItemFk INT) BEGIN /** * Calcula y proporciona un historial de inventario detallado @@ -17,58 +17,58 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory1 SELECT DATE(`date`) `date`, - input, + input, `output`, ok, reference, history.id, warehouse, `name` warehouseName - FROM ( - SELECT tr.landed `date`, + FROM ( + SELECT tr.landed `date`, c.quantity input, NULL `output`, IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, (tr.isReceived <> FALSE) ok, e.invoiceNumber reference, - e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT tr.shipped `date`, + e.id id + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT tr.shipped `date`, NULL input, c.quantity `output`, - warehouseOutFk warehouse, + tr.warehouseOutFk warehouse, tr.isDelivered ok, e.invoiceNumber reference, e.id id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.shipped >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity <> 0 - UNION ALL - SELECT t.shipped `date`, + FROM buy c + JOIN `entry` e ON e.id = c.entryFk + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.shipped >= vDateInventory + AND c.itemFk = vItemFk + AND NOT e.isRaid + AND c.quantity <> 0 + UNION ALL + SELECT t.shipped `date`, NULL input, m.quantity `output`, - warehouseInFk warehouse, + tr.warehouseInFk warehouse, (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, t.refFk reference, t.id id - FROM sale m - JOIN ticket t ON t.id = m.ticketFk - WHERE t.shipped >= vDateInventory - AND m.itemFk = vItemFk - ) history - JOIN warehouse ON warehouse.id = history.warehouse - ORDER BY `date`, input DESC, ok DESC; + FROM sale m + JOIN ticket t ON t.id = m.ticketFk + WHERE t.shipped >= vDateInventory + AND m.itemFk = vItemFk + ) history + JOIN warehouse ON warehouse.id = history.warehouse + ORDER BY `date`, input DESC, ok DESC; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; @@ -86,76 +86,76 @@ BEGIN CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; SELECT * - FROM ( - SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, - NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, - NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, - NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, - NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, - NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, - NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid - FROM tMultipleHistory2 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory3 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory4 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory5 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory6 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory7 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id - FROM tMultipleHistory8 - ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; + FROM ( + SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, + NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, + NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, + NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, + NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, + NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, + NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid + FROM tMultipleHistory2 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory3 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory4 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory5 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory6 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id, + NULL, NULL, NULL, NULL, NULL + FROM tMultipleHistory7 + UNION ALL + SELECT `date`, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, + input, `output`, ok, reference, id + FROM tMultipleHistory8 + ) sub + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10932-azureEucalyptus/00-firstScript.sql b/db/versions/10932-azureEucalyptus/00-firstScript.sql index 55eea3211..399819cc4 100644 --- a/db/versions/10932-azureEucalyptus/00-firstScript.sql +++ b/db/versions/10932-azureEucalyptus/00-firstScript.sql @@ -1,2 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( + vItemFk INT) +BEGIN + DECLARE vDateInventory DATETIME; + SELECT inventoried INTO vDateInventory FROM config; + +END$$ +DELIMITER ; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( + vItemFk INT, vWarehouse INT, vDate DATETIME) +BEGIN + DECLARE vCalculatedInventory INT; + SET vCalculatedInventory = 0; + +END$$ +DELIMITER ; + GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer; GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer; From 7947d6644e5de63988e8845185b7d968efb997ca Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 12:44:59 +0100 Subject: [PATCH 12/42] refs #6498 Correcion errores --- .../procedures/absoluteInventoryHistory.sql | 25 ++++++++++--------- .../procedures/multipleInventoryHistory.sql | 24 ++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index a1e143185..7dce6e252 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -1,6 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`( - vItemFk INT, vWarehouse INT, vDate DATETIME) + vItemFk INT, + vWarehouseFk INT, + vDate DATETIME +) BEGIN /** * Calcula y proporciona un historial de inventario absoluto @@ -8,13 +11,11 @@ BEGIN * hasta una fecha determinada. * * @param vItemFk Id de artículo -* @param vWarehouse Almacén +* @param vWarehouseFk Id de almacén * @param vDate Fecha */ DECLARE vCalculatedInventory INT; - DECLARE vToday DATETIME; - - SET vToday = util.VN_CURDATE(); + DECLARE vToday DATETIME DEFAULT util.VN_CURDATE(); CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast ENGINE = MEMORY @@ -23,7 +24,7 @@ BEGIN SELECT tr.landed `date`, b.quantity input, NULL `output`, - (tr.isReceived != FALSE) ok, + tr.isReceived ok, s.name alias, e.invoiceNumber reference, e.id id, @@ -34,7 +35,7 @@ BEGIN JOIN supplier s ON s.id = e.supplierFk WHERE tr.landed >= '2001-01-01' AND s.id <> 4 - AND vWarehouse IN (tr.warehouseInFk, 0) + AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid @@ -52,7 +53,7 @@ BEGIN JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk WHERE tr.shipped >= '2001-01-01' - AND vWarehouse = tr.warehouseOutFk + AND vWarehouseFk = tr.warehouseOutFk AND s.id <> 4 AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable @@ -61,7 +62,7 @@ BEGIN SELECT t.shipped `date`, NULL input, m.quantity `output`, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, t.nickname alias, t.refFk reference, t.id, @@ -71,16 +72,16 @@ BEGIN JOIN client c ON c.id = t.clientFk WHERE t.shipped >= '2001-01-01' AND m.itemFk = vItemFk - AND vWarehouse IN (t.warehouseFk , 0) + AND vWarehouseFk IN (t.warehouseFk , 0) ) t1 ORDER BY `date`, input DESC, ok DESC; - SELECT sum(input) - sum(`output`) INTO vCalculatedInventory + SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory FROM tHistoricalPast WHERE `date` < vDate; SELECT p1.*, NULL v_virtual - FROM( + FROM ( SELECT vDate `date`, vCalculatedInventory input, NULL `output`, diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index b15cab549..ec151a6ff 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -29,16 +29,16 @@ BEGIN c.quantity input, NULL `output`, IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, - (tr.isReceived <> FALSE) ok, + tr.isReceived ok, e.invoiceNumber reference, - e.id id + e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk JOIN travel tr ON tr.id = e.travelFk WHERE tr.landed >= vDateInventory AND c.itemFk = vItemFk AND NOT e.isRaid - AND c.quantity <> 0 + AND c.quantity UNION ALL SELECT tr.shipped `date`, NULL input, @@ -46,20 +46,20 @@ BEGIN tr.warehouseOutFk warehouse, tr.isDelivered ok, e.invoiceNumber reference, - e.id id + e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk JOIN travel tr ON tr.id = e.travelFk WHERE tr.shipped >= vDateInventory AND c.itemFk = vItemFk AND NOT e.isRaid - AND c.quantity <> 0 + AND c.quantity UNION ALL SELECT t.shipped `date`, NULL input, m.quantity `output`, tr.warehouseInFk warehouse, - (m.isPicked <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) ok, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, t.refFk reference, t.id id FROM sale m @@ -70,13 +70,8 @@ BEGIN JOIN warehouse ON warehouse.id = history.warehouse ORDER BY `date`, input DESC, ok DESC; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory3; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory4; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory5; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory6; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory7; - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory8; + DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3, + tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8; CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; @@ -156,6 +151,7 @@ BEGIN input, `output`, ok, reference, id FROM tMultipleHistory8 ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; + ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, + MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; END$$ DELIMITER ; \ No newline at end of file From 6b2533cfb122ddd832ae9c6a447fe5bbac8b96fa Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 6 Mar 2024 15:16:55 +0100 Subject: [PATCH 13/42] refs #6498 correccion errores 2 --- .../procedures/absoluteInventoryHistory.sql | 41 ++++++++++--------- .../procedures/multipleInventoryHistory.sql | 31 +++++++------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/db/routines/vn/procedures/absoluteInventoryHistory.sql b/db/routines/vn/procedures/absoluteInventoryHistory.sql index 7dce6e252..627b7c8be 100644 --- a/db/routines/vn/procedures/absoluteInventoryHistory.sql +++ b/db/routines/vn/procedures/absoluteInventoryHistory.sql @@ -16,6 +16,7 @@ BEGIN */ DECLARE vCalculatedInventory INT; DECLARE vToday DATETIME DEFAULT util.VN_CURDATE(); + DECLARE vStartDate DATE DEFAULT '2001-01-01'; CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast ENGINE = MEMORY @@ -33,46 +34,46 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - WHERE tr.landed >= '2001-01-01' - AND s.id <> 4 + WHERE tr.landed >= vStartDate + AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND vWarehouseFk IN (tr.warehouseInFk, 0) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid UNION ALL - SELECT tr.shipped `date`, - NULL input, - b.quantity `output`, - tr.isDelivered ok, - s.name alias, - e.invoiceNumber reference, - e.id id, - tr.isDelivered f5 + SELECT tr.shipped, + NULL, + b.quantity, + tr.isDelivered, + s.name, + e.invoiceNumber, + e.id, + tr.isDelivered FROM buy b JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN supplier s ON s.id = e.supplierFk - WHERE tr.shipped >= '2001-01-01' + WHERE tr.shipped >= vStartDate AND vWarehouseFk = tr.warehouseOutFk - AND s.id <> 4 + AND s.id <> (SELECT supplierFk FROM inventoryConfig) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid UNION ALL - SELECT t.shipped `date`, - NULL input, - m.quantity `output`, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, - t.nickname alias, - t.refFk reference, + SELECT t.shipped, + NULL, + m.quantity, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), + t.nickname, + t.refFk, t.id, t.isPrinted FROM sale m JOIN ticket t ON t.id = m.ticketFk JOIN client c ON c.id = t.clientFk - WHERE t.shipped >= '2001-01-01' + WHERE t.shipped >= vStartDate AND m.itemFk = vItemFk - AND vWarehouseFk IN (t.warehouseFk , 0) + AND vWarehouseFk IN (t.warehouseFk, 0) ) t1 ORDER BY `date`, input DESC, ok DESC; diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql index ec151a6ff..dc19e615a 100644 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ b/db/routines/vn/procedures/multipleInventoryHistory.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT) + vItemFk INT +) BEGIN /** * Calcula y proporciona un historial de inventario detallado @@ -28,7 +29,7 @@ BEGIN SELECT tr.landed `date`, c.quantity input, NULL `output`, - IF(warehouseInFk = 44, 1, warehouseInFk) warehouse, + tr.warehouseInFk warehouse, tr.isReceived ok, e.invoiceNumber reference, e.id @@ -40,12 +41,12 @@ BEGIN AND NOT e.isRaid AND c.quantity UNION ALL - SELECT tr.shipped `date`, - NULL input, - c.quantity `output`, - tr.warehouseOutFk warehouse, - tr.isDelivered ok, - e.invoiceNumber reference, + SELECT tr.shipped, + NULL, + c.quantity, + tr.warehouseOutFk, + tr.isDelivered, + e.invoiceNumber, e.id FROM buy c JOIN `entry` e ON e.id = c.entryFk @@ -55,13 +56,13 @@ BEGIN AND NOT e.isRaid AND c.quantity UNION ALL - SELECT t.shipped `date`, - NULL input, - m.quantity `output`, - tr.warehouseInFk warehouse, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL) ok, - t.refFk reference, - t.id id + SELECT t.shipped, + NULL, + m.quantity, + t.warehouseFk, + (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), + t.refFk, + t.id FROM sale m JOIN ticket t ON t.id = m.ticketFk WHERE t.shipped >= vDateInventory From b588b9807ce73a19f6f2a7f48828a6ab487990e5 Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 7 Mar 2024 13:45:53 +0100 Subject: [PATCH 14/42] fixtures local --- db/dump/fixtures.after.sql | 411 ------------------------------------- 1 file changed, 411 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 13e423d68..4c5f89d97 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -292,418 +292,7 @@ INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount */ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); --- XXX: floranet -INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); - - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNR', 'Floranet Ramos', 1, 1); - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNP', 'Floranet Plantas', 1, 1); - --- Generación de items -SELECT id - INTO @FNR - FROM vn.itemType - WHERE code = 'FNR'; - -SELECT id - INTO @FNP - FROM vn.itemType - WHERE code = 'FNP'; - -DELETE - FROM vn.item - WHERE typeFk IN (@FNR,@FNP); - -SELECT MAX(id) + 1 - INTO @item - FROM vn.item; - -INSERT INTO vn.item - ( - id, - name, - longName, - `size`, - originFk, - intrastatFk, - typeFk, - inkFk, - image, - description - ) - VALUES - ( - @item := @item + 1, - @r := 'Ramo Terranova', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1CwtEK5_GReAzconaJsPTCXxV7zajbTos/view?usp=drive_link', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', - 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', - 'paniculata eucaliptus.') - ), - ( - @item := @item + 1, - @r := 'Ramo Tasmania', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1_149uYZ-sehw3vWH68Quttk8QJe5T_bG/view?usp=drive_link', - CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', - 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', - 'flores será un acierto seguro para hacer un regalo muy especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Pasion', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1-dH1UilV-nOH9XNK23uooZoezlwMT-Jq/view?usp=drive_link', - CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', - 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', - 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', - 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', - 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') - ), - ( - @item := @item + 1, - @r := 'Ramo Florencia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1PWKo5N8kg8H3xQtELdeQTQIc1HMZCc1P/view?usp=drive_link', - CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', - 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', - 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', - 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Atardecer', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink WHERE name = 'Yellow'), - 'https://drive.google.com/file/d/1eM4gtftQuXN5xUjAHIRUYNPZNmuHVRA_/view?usp=drive_link', - CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', - 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', - 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', - 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', - 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') - ), - ( - @item := @item + 1, - @r := 'Ramo Arcoíris', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1Hxk5yqo7891gfK1VKIYfWxO5a_0K2Qej/view?usp=drive_link', - CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', - 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', - 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', - 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', - 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', - 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') - ), - ( - @item := @item + 1, - @r := 'Ramo Provenza', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1TA9SBwjqnrEqG1bzwDL37sxtX9CNyLJk/view?usp=drive_link', - CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', - 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', - 'con una selección de maravillosos verdes variados, hacen que esta combinación ', - 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') - ), - ( - @item := @item + 1, - @r := 'Ramo Alegria', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1sOf2isj84P9OxR3E3x6n2PjPnWVamLCE/view?usp=drive_link', - CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', - 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', - ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', - 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', - 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') - ), - ( - @item := @item + 1, - @r := 'Planta Orquídeas ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/14BIkDDonFaIiTyJer1CWju1YzZNzt3XQ/view?usp=drive_link', - CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', - 'con las mejores características combinadas con diferentes elementos de ', - 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', - 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', - 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', - 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') - ), - ( - @item := @item + 1, - @r := 'Planta Kentia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1rKe2RicfWha-VIm1LbbXckbA41glA99K/view?usp=drive_link', - CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', - 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', - 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', - 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', - 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', - 'de ser un producto nacional producido en Canarias de una calidad extrema.') - ), - ( - @item := @item + 1, - @r := 'Planta Calathea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/11CKm5rqVFVPOELciuyXUrkc2oeTHJzBE/view?usp=drive_link', - CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', - ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', - 'llamativo y original colorido, tambien es un regalo perfecto para ', - 'cualquier compromiso que tengamos .') - ), - ( - @item := @item + 1, - @r := 'Planta Anthurium ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink WHERE name = 'Red'), - 'https://drive.google.com/file/d/1j4il_N9VJGaP4f6CPZM0u6GjxwIeYcBt/view?usp=drive_link', - CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', - 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', - 'su llamativo color alegrará cualquier celebración') - ), - ( - @item := @item + 1, - @r := 'Ramo Mindanao', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1lsGDuC6xmv3SyGukfLTVYsQvbGf1Bzxy/view?usp=drive_link', - CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', - 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', - 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') - ), - ( - @item := @item + 1, - @r := 'Ramo Guinea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1MtF0oghv-ahogaAaVpJNzDiIfyeCCmAi/view?usp=drive_link', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', - ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') - ), - ( - @item := @item + 1, - @r := 'Ramo Eterno', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/1AOMqlZAKqImnnWSmeq1DW1Krj78mACCG/view?usp=drive_link', - CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', - 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', - 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', - 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', - 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', - 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') - ), - ( - @item := @item + 1, - @r := 'Ramo Cielo', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - 'https://drive.google.com/file/d/168DikIOwVT5OO4BHARBoWwLB1wjpAS7s/view?usp=drive_link', - CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', - 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', - ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', - 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', - ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', - 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', - 'clara de todo el conjunto. ') - ); - - -- Ramo Terranova: 1er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Rosa roja', - @r, - 60, - 1, - 'RED', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 12 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - -- Ramo Terranova: 2º elemento - -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Hoja de helecho', - @r, - 60, - 1, - 'BAS', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 4 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- Ramo Terranova: 3er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Paniculata', - @r, - 60, - 1, - 'SLV', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 5 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- XXX SET foreign_key_checks = 1; From 25f979156ade5b2fe7afe9fcd103f0a2fe183c1c Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Mar 2024 14:00:59 +0100 Subject: [PATCH 15/42] nuevo url para catalogue y sliders_get --- .../floranet/procedures/catalogue_get.sql | 2 +- ...ontact_Request.sql => contact_request.sql} | 4 ++-- .../floranet/procedures/sliders_get.sql | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) rename db/routines/floranet/procedures/{contact_Request.sql => contact_request.sql} (68%) create mode 100644 db/routines/floranet/procedures/sliders_get.sql diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index 914b5d27f..b6ec61522 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -36,7 +36,7 @@ BEGIN vLanded, vPostalCode, it.name, - i.image, + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), i.description FROM vn.item i JOIN vn.itemType it ON it.id = i.typeFk diff --git a/db/routines/floranet/procedures/contact_Request.sql b/db/routines/floranet/procedures/contact_request.sql similarity index 68% rename from db/routines/floranet/procedures/contact_Request.sql rename to db/routines/floranet/procedures/contact_request.sql index 7673c2203..044c22c6f 100644 --- a/db/routines/floranet/procedures/contact_Request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -1,9 +1,9 @@ -DROP PROCEDURE IF EXISTS floranet.contact_Request; +DROP PROCEDURE IF EXISTS floranet.contact_request; DELIMITER $$ $$ CREATE DEFINER=`root`@`localhost` -PROCEDURE floranet.contact_Request( +PROCEDURE floranet.contact_request( vName VARCHAR(100), vPhone VARCHAR(15), vEmail VARCHAR(100), diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql new file mode 100644 index 000000000..2f77b8534 --- /dev/null +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -0,0 +1,19 @@ +DROP PROCEDURE IF EXISTS floranet.sliders_get; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get() +READS SQL DATA +BEGIN +/** + * Returns list of url for sliders + */ + SELECT + CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, + i.longName + FROM vn.item i + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.code IN ('FNR','FNP'); + +END$$ +DELIMITER ; \ No newline at end of file From 67b55ae845b7843038032038f57f7a37aceafbaf Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Mar 2024 14:16:27 +0100 Subject: [PATCH 16/42] fixtures local --- db/.gitignore | 2 +- db/dump/fixtures.local.sql | 406 +++++++++++++++++++++++++++++++++++++ 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 db/dump/fixtures.local.sql diff --git a/db/.gitignore b/db/.gitignore index 54ed9df77..231f0dfe0 100644 --- a/db/.gitignore +++ b/db/.gitignore @@ -4,7 +4,7 @@ remotes/*.ini !remotes/local.ini !remotes/docker.ini dump/.changes -dump/fixtures.local.sql +#dump/fixtures.local.sql .dBeaver .idea .project diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql new file mode 100644 index 000000000..64d22f480 --- /dev/null +++ b/db/dump/fixtures.local.sql @@ -0,0 +1,406 @@ +-- XXX: floranet + +INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) +VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); + + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNR', 'Floranet Ramos', 1, 1); + +INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) + VALUES('FNP', 'Floranet Plantas', 1, 1); + +-- Generación de items +SELECT id + INTO @FNR + FROM vn.itemType + WHERE code = 'FNR'; + +SELECT id + INTO @FNP + FROM vn.itemType + WHERE code = 'FNP'; + +DELETE + FROM vn.item + WHERE typeFk IN (@FNR,@FNP); + +INSERT INTO vn.item + ( + id, + name, + longName, + `size`, + originFk, + intrastatFk, + typeFk, + inkFk, + image, + description + ) + VALUES + ( + 147791, + @r := 'Ramo Terranova', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147791', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', + 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', + 'paniculata eucaliptus.') + ), + ( + 147792, + @r := 'Ramo Tasmania', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147792', + CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', + 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', + 'flores será un acierto seguro para hacer un regalo muy especial.') + ), + ( + 147793, + @r := 'Ramo Pasion', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147793', + CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', + 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', + 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', + 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', + 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') + ), + ( + 147794, + @r := 'Ramo Florencia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147794', + CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', + 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', + 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', + 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') + ), + ( + 147795, + @r := 'Ramo Atardecer', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink WHERE name = 'Yellow'), + '147795', + CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', + 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', + 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', + 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', + 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') + ), + ( + 147796, + @r := 'Ramo Arcoíris', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147796', + CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', + 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', + 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', + 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', + 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', + 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') + ), + ( + 147797, + @r := 'Ramo Provenza', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147797', + CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', + 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', + 'con una selección de maravillosos verdes variados, hacen que esta combinación ', + 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') + ), + ( + 147798, + @r := 'Ramo Alegria', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147798', + CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', + 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', + ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', + 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', + 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') + ), + ( + 147799, + @r := 'Planta Orquídeas ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147799', + CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', + 'con las mejores características combinadas con diferentes elementos de ', + 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', + 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', + 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', + 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') + ), + ( + 147800, + @r := 'Planta Kentia', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147800', + CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', + 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', + 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', + 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', + 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', + 'de ser un producto nacional producido en Canarias de una calidad extrema.') + ), + ( + 147801, + @r := 'Planta Calathea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147801', + CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', + ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', + 'llamativo y original colorido, tambien es un regalo perfecto para ', + 'cualquier compromiso que tengamos .') + ), + ( + 147802, + @r := 'Planta Anthurium ', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNP, + (SELECT id FROM vn.ink WHERE name = 'Red'), + '147802', + CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', + 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', + 'su llamativo color alegrará cualquier celebración') + ), + ( + 147803, + @r := 'Ramo Mindanao', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147803', + CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', + 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', + 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') + ), + ( + 147804, + @r := 'Ramo Guinea', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147804', + CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', + ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') + ), + ( + 147805, + @r := 'Ramo Eterno', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147805', + CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', + 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', + 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', + 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', + 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', + 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') + ), + ( + 147806, + @r := 'Ramo Cielo', + @r, + 20 + CEIL(RAND() * 55), + (SELECT id FROM vn.origin WHERE code = 'SPA'), + 6031970, + @FNR, + (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), + '147806', + CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', + 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', + ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', + 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', + ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', + 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', + 'clara de todo el conjunto. ') + ); + + -- Ramo Terranova: 1er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Rosa roja', + @r, + 60, + 1, + 'RED', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 12 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + -- Ramo Terranova: 2º elemento + +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Hoja de helecho', + @r, + 60, + 1, + 'BAS', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 4 + FROM vn.item + WHERE name = 'Ramo Terranova'; + + + -- Ramo Terranova: 3er elemento +INSERT INTO vn.item( + name, + longName, + `size`, + stems, + inkFk, + intrastatFk, + typeFk, + originFk) + SELECT + @r:= 'Paniculata', + @r, + 60, + 1, + 'SLV', + 6031970, + id, + 1 + FROM vn.itemType + WHERE code LIKE 'FNE'; + +SELECT LAST_INSERT_ID() INTO @itemFk; + +INSERT INTO floranet.`element` + SET itemFk = @itemFk; + +INSERT INTO floranet.builder( + itemFk, + elementFk, + quantity) + SELECT + id, + @itemFk, + 5 + FROM vn.item + WHERE name = 'Ramo Terranova'; + From fbeb9b058d4ca6367b4e003142b29c4ec09ffb5c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Mar 2024 09:34:37 +0100 Subject: [PATCH 17/42] hotfix: itemProposal added optimizer_search_depth --- db/routines/vn/procedures/itemProposal.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/itemProposal.sql b/db/routines/vn/procedures/itemProposal.sql index 0dc04124d..da9e757aa 100644 --- a/db/routines/vn/procedures/itemProposal.sql +++ b/db/routines/vn/procedures/itemProposal.sql @@ -18,21 +18,17 @@ BEGIN DECLARE vCalcFk INT; DECLARE vTypeFk INT; DECLARE vPriority INT DEFAULT 1; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; SELECT warehouseFk, shipped INTO vWarehouseFk, vShipped FROM ticket WHERE id = vTicketFk; - START TRANSACTION; - CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vShipped); + SET @_optimizer_search_depth = @@optimizer_search_depth; + SET SESSION optimizer_search_depth = 0; + WITH itemTags AS ( SELECT i.id, typeFk, @@ -99,6 +95,7 @@ BEGIN match7 DESC, (i.tag8 = its.tag8) DESC, match8 DESC; - COMMIT; + + SET SESSION optimizer_search_depth = @_optimizer_search_depth; END$$ DELIMITER ; From 184a3a3c7a453a1337e171d02970ecce9fb32db1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 14 Mar 2024 10:05:25 +0100 Subject: [PATCH 18/42] refs #6395 Requested changes --- db/routines/vn/triggers/buy_beforeInsert.sql | 9 ++++++++- db/routines/vn/triggers/buy_beforeUpdate.sql | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index c698e23e6..a05f2810b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -9,6 +9,7 @@ trig: BEGIN DECLARE vGroupingMode TINYINT; DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; + DECLARE vBuyerFk INT; IF @isModeInventory THEN LEAVE trig; @@ -19,7 +20,13 @@ trig: BEGIN END IF; SET NEW.editorFk = account.myUser_getId(); - SET NEW.buyerFk = NEW.editorFk; + + SELECT it.workerFk INTO vBuyerFk + FROM item i + JOIN itemType it ON it.id = i.typeFk + WHERE i.id = NEW.itemFk; + + SET NEW.buyerFk = vBuyerFk; CALL buy_checkGrouping(NEW.`grouping`); diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index b41418bcc..40e0df984 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -7,6 +7,7 @@ trig:BEGIN DECLARE vGenericInDate BOOL; DECLARE vIsInventory BOOL; DECLARE vDefaultEntry INT; + DECLARE vBuyerFk INT; IF @isTriggerDisabled THEN LEAVE trig; @@ -66,7 +67,12 @@ trig:BEGIN END IF; IF NOT (NEW.itemFk <=> OLD.itemFk) THEN - SET NEW.buyerFk = NEW.editorFk; + SELECT it.workerFk INTO vBuyerFk + FROM item i + JOIN itemType it ON it.id = i.typeFk + WHERE i.id = NEW.itemFk; + + SET NEW.buyerFk = vBuyerFk; END IF; IF NOT (NEW.itemFk <=> OLD.itemFk) OR From 160d72e755ec57372d9b29601910c084f0de19ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 14 Mar 2024 17:02:07 +0100 Subject: [PATCH 19/42] hotfix upload invoiceIn_add.sql error --- db/routines/sage/procedures/invoiceIn_add.sql | 96 ++++--- db/routines/vn/procedures/invoiceIn_add.sql | 234 ------------------ 2 files changed, 64 insertions(+), 266 deletions(-) delete mode 100644 db/routines/vn/procedures/invoiceIn_add.sql diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index a2690deb0..0898d6810 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vI BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas - * + * * @vInvoiceInFk Factura recibida * @vXDiarioFk Id tabla XDiario - */ + */ + DECLARE vInvoiceInOriginalFk INT; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -23,25 +24,25 @@ BEGIN DECLARE vInvoiceTypeInformative VARCHAR(1); DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; - DECLARE vCursor CURSOR FOR + DECLARE vCursor CURSOR FOR SELECT it.taxableBase, CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, it.taxTypeSageFk, tty.isIntracommunity, - tt.ClaveOperacionDefecto + tt.ClaveOperacionDefecto FROM vn.invoiceIn i JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk JOIN taxType tty ON tty.id = t.CodigoIva JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk LEFT JOIN vn.dua d ON d.id = vInvoiceInFk - WHERE i.id = vInvoiceInFk + WHERE i.id = vInvoiceInFk AND d.id IS NULL; - + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + DELETE FROM movContaIVA WHERE id = vXDiarioFk; @@ -64,22 +65,22 @@ BEGIN vTaxCode, vIsIntracommunity, vOperationCode; - - IF vDone THEN + + IF vDone THEN LEAVE l; END IF; - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; - IF vOperationCode IS NOT NULL THEN + IF vOperationCode IS NOT NULL THEN UPDATE movContaIVA SET ClaveOperacionFactura = vOperationCode WHERE id = vXDiarioFk; END IF; - + SET vCounter = vCounter + 1; - CASE vCounter + CASE vCounter WHEN 1 THEN UPDATE movContaIVA SET BaseIva1 = vBase, @@ -115,31 +116,31 @@ BEGIN WHERE id = vXDiarioFk; ELSE SELECT vXDiarioFk INTO vXDiarioFk; - END CASE; + END CASE; IF vIsIntracommunity THEN UPDATE movContaIVA SET Intracomunitaria = TRUE WHERE id = vXDiarioFk; END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - + + SET vTransactionCodeOld = vTransactionCode; + SET vTaxCodeOld = vTaxCode; + END LOOP; CLOSE vCursor; SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation FROM vn.dua d - LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN + LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci WHERE d.ASIEN = ( SELECT ASIEN - FROM vn.XDiario + FROM vn.XDiario WHERE id = vXDiarioFk) LIMIT 1; - + UPDATE movContaIVA mci JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk JOIN vn.XDiario x ON x.id = mci.id @@ -151,13 +152,13 @@ BEGIN mci.Serie = ii.serial, mci.Factura = ii.id, mci.FechaFactura = ii.issued, - mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + + mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + + IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + + IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, - IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), - IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), + mci.TipoFactura = IF(id.id, + IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), + IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), mci.CodigoCuentaFactura = x.SUBCTA, mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), mci.Nombre = s.name, @@ -185,7 +186,7 @@ BEGIN JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase FROM vn.XDiario x1 JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN - WHERE x2.BASEEURO <> 0 + WHERE x2.BASEEURO <> 0 AND x1.id = vXDiarioFk )sub JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio' @@ -193,10 +194,41 @@ BEGIN mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura), mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase), mci.PorRetencion = t.PorcentajeRetencion, - mci.ImporteRetencion = iit.taxableBase * - 1 - WHERE mci.id = vXDiarioFk + mci.ImporteRetencion = iit.taxableBase * - 1 + WHERE mci.id = vXDiarioFk AND e.name = 'Retenciones' AND id.id IS NULL; + SELECT correctedFk INTO vInvoiceInOriginalFk + FROM vn.invoiceInCorrection + WHERE correctingFk = vInvoiceInFk; + + IF vInvoiceInOriginalFk THEN + + UPDATE movContaIVA mci + JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk + JOIN (SELECT issued, + SUM(sub.taxableBase) taxableBase, + SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat + FROM(SELECT issued, + SUM(iit.taxableBase) taxableBase, + ti.PorcentajeIva + FROM vn.invoiceIn i + JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id + JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + WHERE i.id = vInvoiceInOriginalFk + GROUP BY ti.CodigoIva)sub + )invoiceInOriginal + JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' + SET mci.TipoRectificativa = iir.refundCategoryFk, + mci.ClaseAbonoRectificativas = iir.refundType, + mci.FechaFacturaOriginal = invoiceInOriginal.issued, + mci.FechaOperacion = invoiceInOriginal.issued, + mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, + mci.CuotaIvaOriginal = invoiceInOriginal.vat, + mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ + WHERE mci.id = vXDiarioFk; + + END IF; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/invoiceIn_add.sql b/db/routines/vn/procedures/invoiceIn_add.sql deleted file mode 100644 index 0898d6810..000000000 --- a/db/routines/vn/procedures/invoiceIn_add.sql +++ /dev/null @@ -1,234 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT) -BEGIN -/** - * Traslada la info de contabilidad relacionada con las facturas recibidas - * - * @vInvoiceInFk Factura recibida - * @vXDiarioFk Id tabla XDiario - */ - DECLARE vInvoiceInOriginalFk INT; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vBase DOUBLE; - DECLARE vVat DOUBLE; - DECLARE vRate DOUBLE; - DECLARE vTransactionCode INT; - DECLARE vCounter INT DEFAULT 0; - DECLARE vTransactionCodeOld INT; - DECLARE vTaxCode INT; - DECLARE vTaxCodeOld INT; - DECLARE vOperationCode VARCHAR(1); - DECLARE vIsIntracommunity BOOL DEFAULT FALSE; - DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; - DECLARE vInvoiceTypeReceived VARCHAR(1); - DECLARE vInvoiceTypeInformative VARCHAR(1); - DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; - - DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, - CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), - t.PorcentajeIva, - it.transactionTypeSageFk, - it.taxTypeSageFk, - tty.isIntracommunity, - tt.ClaveOperacionDefecto - FROM vn.invoiceIn i - JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id - JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk - JOIN taxType tty ON tty.id = t.CodigoIva - JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk - LEFT JOIN vn.dua d ON d.id = vInvoiceInFk - WHERE i.id = vInvoiceInFk - AND d.id IS NULL; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - DELETE FROM movContaIVA - WHERE id = vXDiarioFk; - - SELECT codeSage INTO vInvoiceTypeReceived - FROM invoiceType WHERE code ='received'; - - SELECT codeSage INTO vInvoiceTypeInformative - FROM invoiceType WHERE code ='informative'; - - INSERT INTO movContaIVA(id, LibreA1) - VALUES (vXDiarioFk, vInvoiceInFk); - - OPEN vCursor; - - l: LOOP - FETCH vCursor INTO vBase, - vVat, - vRate, - vTransactionCode, - vTaxCode, - vIsIntracommunity, - vOperationCode; - - IF vDone THEN - LEAVE l; - END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - - IF vOperationCode IS NOT NULL THEN - UPDATE movContaIVA - SET ClaveOperacionFactura = vOperationCode - WHERE id = vXDiarioFk; - END IF; - - SET vCounter = vCounter + 1; - CASE vCounter - WHEN 1 THEN - UPDATE movContaIVA - SET BaseIva1 = vBase, - PorIva1 = vRate, - CuotaIva1 = vVat, - CodigoTransaccion1 = vTransactionCode, - CodigoIva1 = vTaxCode - WHERE id = vXDiarioFk; - - WHEN 2 THEN - UPDATE movContaIVA - SET BaseIva2 = vBase, - PorIva2 = vRate, - CuotaIva2 = vVat, - CodigoTransaccion2 = vTransactionCode, - CodigoIva2 = vTaxCode - WHERE id = vXDiarioFk; - WHEN 3 THEN - UPDATE movContaIVA - SET BaseIva3 = vBase, - PorIva3 = vRate, - CuotaIva3 = vVat, - CodigoTransaccion3 = vTransactionCode, - CodigoIva3 = vTaxCode - WHERE id = vXDiarioFk; - WHEN 4 THEN - UPDATE movContaIVA - SET BaseIva4 = vBase, - PorIva4 = vRate, - CuotaIva4 = vVat, - CodigoTransaccion4 = vTransactionCode, - CodigoIva4 = vTaxCode - WHERE id = vXDiarioFk; - ELSE - SELECT vXDiarioFk INTO vXDiarioFk; - END CASE; - - IF vIsIntracommunity THEN - UPDATE movContaIVA - SET Intracomunitaria = TRUE - WHERE id = vXDiarioFk; - END IF; - - SET vTransactionCodeOld = vTransactionCode; - SET vTaxCodeOld = vTaxCode; - - END LOOP; - - CLOSE vCursor; - - SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation - FROM vn.dua d - LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN - AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci - WHERE d.ASIEN = ( - SELECT ASIEN - FROM vn.XDiario - WHERE id = vXDiarioFk) - LIMIT 1; - - UPDATE movContaIVA mci - JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk - JOIN vn.XDiario x ON x.id = mci.id - LEFT JOIN tmp.invoiceDua id ON id.id = mci.id - JOIN vn.supplier s ON s.id = ii.supplierFk - JOIN Naciones n ON n.countryFk = s.countryFk - SET mci.CodigoDivisa = ii.currencyFk, - mci.Año = YEAR(ii.issued), - mci.Serie = ii.serial, - mci.Factura = ii.id, - mci.FechaFactura = ii.issued, - mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) + - IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) + - IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) + - IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0), - mci.TipoFactura = IF(id.id, - IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative), - IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)), - mci.CodigoCuentaFactura = x.SUBCTA, - mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif), - mci.Nombre = s.name, - mci.SiglaNacion = n.SiglaNacion, - mci.EjercicioFactura = YEAR(ii.issued), - mci.FechaOperacion = ii.issued, - mci.MantenerAsiento = TRUE, - mci.SuFacturaNo = ii.supplierRef, - mci.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)), - mci.FechaFacturaOriginal = x.FECHA_EX - WHERE mci.id = vXDiarioFk; - - -- RETENCIONES - UPDATE movContaIVA mci - JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk - JOIN vn.XDiario x ON x.id = mci.id - JOIN vn.supplier s ON s.id = supplierFk - JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN vn.expense e ON e.id = iit.expenseFk - JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk - LEFT JOIN tmp.invoiceDua id ON id.id = mci.id - JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase - FROM vn.XDiario x1 - JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN - WHERE x2.BASEEURO <> 0 - AND x1.id = vXDiarioFk - )sub - JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio' - SET mci.CodigoRetencion = t.CodigoRetencion, - mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura), - mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase), - mci.PorRetencion = t.PorcentajeRetencion, - mci.ImporteRetencion = iit.taxableBase * - 1 - WHERE mci.id = vXDiarioFk - AND e.name = 'Retenciones' - AND id.id IS NULL; - - SELECT correctedFk INTO vInvoiceInOriginalFk - FROM vn.invoiceInCorrection - WHERE correctingFk = vInvoiceInFk; - - IF vInvoiceInOriginalFk THEN - - UPDATE movContaIVA mci - JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk - JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, - SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat - FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, - ti.PorcentajeIva - FROM vn.invoiceIn i - JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk - WHERE i.id = vInvoiceInOriginalFk - GROUP BY ti.CodigoIva)sub - )invoiceInOriginal - JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, - mci.FechaFacturaOriginal = invoiceInOriginal.issued, - mci.FechaOperacion = invoiceInOriginal.issued, - mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, - mci.CuotaIvaOriginal = invoiceInOriginal.vat, - mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ - WHERE mci.id = vXDiarioFk; - - END IF; -END$$ -DELIMITER ; \ No newline at end of file From 158ed9b55c30a21f5e82a1bc5b8834443342b78a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 11:49:33 +0100 Subject: [PATCH 20/42] refs #6232 Regularized config tables --- db/dump/fixtures.after.sql | 4 +- db/dump/fixtures.before.sql | 43 +++++------ db/versions/10953-redChico/00-account.sql | 23 ++++++ db/versions/10953-redChico/01-bs.sql | 7 ++ db/versions/10953-redChico/02-edi.sql | 15 ++++ db/versions/10953-redChico/03-hedera.sql | 27 +++++++ db/versions/10953-redChico/04-pbx.sql | 15 ++++ db/versions/10953-redChico/05-sage.sql | 3 + db/versions/10953-redChico/06-salix.sql | 7 ++ db/versions/10953-redChico/06-srt.sql | 3 + db/versions/10953-redChico/07-util.sql | 11 +++ db/versions/10953-redChico/08-vn.sql | 87 ++++++++++++++++++++++ db/versions/10953-redChico/08-vn2.sql | 91 +++++++++++++++++++++++ 13 files changed, 313 insertions(+), 23 deletions(-) create mode 100644 db/versions/10953-redChico/00-account.sql create mode 100644 db/versions/10953-redChico/01-bs.sql create mode 100644 db/versions/10953-redChico/02-edi.sql create mode 100644 db/versions/10953-redChico/03-hedera.sql create mode 100644 db/versions/10953-redChico/04-pbx.sql create mode 100644 db/versions/10953-redChico/05-sage.sql create mode 100644 db/versions/10953-redChico/06-salix.sql create mode 100644 db/versions/10953-redChico/06-srt.sql create mode 100644 db/versions/10953-redChico/07-util.sql create mode 100644 db/versions/10953-redChico/08-vn.sql create mode 100644 db/versions/10953-redChico/08-vn2.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index bda625a96..1c3a4a960 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -7,8 +7,8 @@ SET foreign_key_checks = 0; -- XXX: vn-database -INSERT INTO util.config (environment, mockTime, mockUtcTime, mockEnabled) - VALUES ('local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); +INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) + VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) VALUES(1, NULL, 1, 300, 1); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8ea0baff2..3cf9cd928 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -60,13 +60,13 @@ INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); -INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) +INSERT INTO `vn`.`bionicConfig` (`id`, `generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) VALUES - (1.30, 167.00, 138000, 71); + (1, 1.30, 167.00, 138000, 71); -INSERT INTO `vn`.`chatConfig` (`host`, `api`) +INSERT INTO `vn`.`chatConfig` (`id`, `host`, `api`) VALUES - ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); + (1, 'https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) VALUES @@ -608,7 +608,8 @@ INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion` ('WORLD', 2, 15); INSERT INTO vn.invoiceOutConfig - SET parallelism = 8; + SET id = 1, + parallelism = 8; INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaFk`, `isCEE`, `type`) VALUES @@ -714,7 +715,7 @@ INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) (12, util.VN_CURDATE(), '23:59'), (13, util.VN_CURDATE(), '23:59'); -INSERT INTO `vn`.`zoneConfig` (`scope`) VALUES ('1'); +INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1'); INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) VALUES @@ -983,9 +984,9 @@ INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPack ('cc', 1640038.00, 56.00, 220.00, 128.00, 1, util.VN_CURDATE(), 15, 90.00), ('pallet 100', 2745600.00, 100.00, 220.00, 120.00, 1, util.VN_CURDATE(), 16, 0.00); -INSERT INTO `vn`.`packagingConfig`(`upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`) +INSERT INTO `vn`.`packagingConfig`(`id`, `upperGap`, `defaultSmallPackageFk`, `defaultBigPackageFk`) VALUES - ('10', 1, 'pallet 100'); + (1, '10', 1, 'pallet 100'); INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) VALUES @@ -1868,8 +1869,7 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) VALUES - (1, 50), - (2, 30); + (1, 50); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -2504,9 +2504,9 @@ INSERT INTO `hedera`.`imageCollectionSize`(`id`, `collectionFk`,`width`, `height VALUES (1, 4, 160, 160); -INSERT INTO `vn`.`rateConfig`(`rate0`, `rate1`, `rate2`, `rate3`) +INSERT INTO `vn`.`rateConfig`(`id`, `rate0`, `rate1`, `rate2`, `rate3`) VALUES - (36, 31, 25, 21); + (1, 36, 31, 25, 21); INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate3`) VALUES @@ -2697,9 +2697,9 @@ INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) (4, 33.8, util.VN_CURDATE(), 1, 1101), (30, 34.4, util.VN_CURDATE(), 1, 1108); -INSERT INTO `vn`.`docuwareConfig` (`url`) +INSERT INTO `vn`.`docuwareConfig` (`id`, `url`) VALUES - ('http://docuware.url/'); + (1, 'http://docuware.url/'); INSERT INTO `vn`.`calendarHolidaysName` (`id`, `name`) VALUES @@ -2796,11 +2796,12 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) VALUES (1, 'h1', 1, ''); -INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) +INSERT INTO `vn`.`packingSiteConfig` (`id`, `shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) VALUES - ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); + (1, '', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); INSERT INTO `util`.`notificationConfig` - SET `cleanDays` = 90; + SET `id` = 1, + `cleanDays` = 90; INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES @@ -2853,7 +2854,7 @@ INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPack INSERT INTO `vn`.`itemConfig` (`id`, `isItemTagTriggerDisabled`, `monthToDeactivate`, `wasteRecipients`, `validPriorities`, `defaultPriority`, `defaultTag`, `warehouseFk`) VALUES - (0, 0, 24, '', '[1,2,3]', 2, 56, 60); + (1, 0, 24, '', '[1,2,3]', 2, 56, 60); INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `level`, `wagon`, `smartTagFk`, `usedShelves`, `itemCount`, `liters`) VALUES @@ -2890,7 +2891,7 @@ INSERT INTO `vn`.`ticketLog` (originFk, userFk, `action`, creationDate, changedM (1, 18, 'insert', '1999-05-09 10:00:00', 'Ticket', 45, 'Super Man' , NULL, '{"id":45,"clientFk":8608,"warehouseFk":60,"shipped":"2023-05-16T22:00:00.000Z","nickname":"Super Man","addressFk":48637,"isSigned":true,"isLabeled":true,"isPrinted":true,"packages":0,"hour":0,"created":"2023-05-16T11:42:56.000Z","isBlocked":false,"hasPriority":false,"companyFk":442,"agencyModeFk":639,"landed":"2023-05-17T22:00:00.000Z","isBoxed":true,"isDeleted":true,"zoneFk":713,"zonePrice":13,"zoneBonus":0}', NULL); INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) VALUES - (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); + (1, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', '1,6', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) VALUES @@ -3711,8 +3712,8 @@ UPDATE vn.collection UPDATE vn.sale SET isPicked =FALSE; -INSERT INTO vn.machineWorkerConfig(maxHours) - VALUES(12); +INSERT INTO vn.machineWorkerConfig(id, maxHours) + VALUES(1, 12); INSERT INTO vn.workerAppTester(workerFk) VALUES(66); diff --git a/db/versions/10953-redChico/00-account.sql b/db/versions/10953-redChico/00-account.sql new file mode 100644 index 000000000..e6944a686 --- /dev/null +++ b/db/versions/10953-redChico/00-account.sql @@ -0,0 +1,23 @@ +-- account.accountConfig +ALTER TABLE account.accountConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE account.accountConfig ADD CONSTRAINT accountConfig_check CHECK (id = 1); + +-- account.ldapConfig +ALTER TABLE account.ldapConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.ldapConfig ADD CONSTRAINT ldapConfig_check CHECK (id = 1); + +-- account.mailConfig +ALTER TABLE account.mailConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1); + +-- account.roleConfig +ALTER TABLE account.roleConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.roleConfig ADD CONSTRAINT roleConfig_check CHECK (id = 1); + +-- account.sambaConfig +ALTER TABLE account.sambaConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE account.sambaConfig ADD CONSTRAINT sambaConfig_check CHECK (id = 1); + +-- account.userConfig +ALTER TABLE account.userConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE account.userConfig ADD CONSTRAINT userConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/01-bs.sql b/db/versions/10953-redChico/01-bs.sql new file mode 100644 index 000000000..e451c8205 --- /dev/null +++ b/db/versions/10953-redChico/01-bs.sql @@ -0,0 +1,7 @@ +-- bs.nightTaskConfig +ALTER TABLE bs.nightTaskConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE bs.nightTaskConfig ADD CONSTRAINT nightTaskConfig_check CHECK (id = 1); + +-- bs.workerProductivityConfig +ALTER TABLE bs.workerProductivityConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE bs.workerProductivityConfig ADD CONSTRAINT workerProductivityConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/02-edi.sql b/db/versions/10953-redChico/02-edi.sql new file mode 100644 index 000000000..e97cfcec8 --- /dev/null +++ b/db/versions/10953-redChico/02-edi.sql @@ -0,0 +1,15 @@ +-- edi.exchangeConfig +ALTER TABLE edi.exchangeConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE edi.exchangeConfig ADD CONSTRAINT exchangeConfig_check CHECK (id = 1); + +-- edi.ftpConfig +ALTER TABLE edi.ftpConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE edi.ftpConfig ADD CONSTRAINT ftpConfig_check CHECK (id = 1); + +-- edi.imapConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE edi.imapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +-- ALTER TABLE edi.imapConfig ADD CONSTRAINT imapConfig_check CHECK (id = 1); + +-- edi.offerRefreshConfig +ALTER TABLE edi.offerRefreshConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE edi.offerRefreshConfig ADD CONSTRAINT offerRefreshConfig_check CHECK (id = 1); \ No newline at end of file diff --git a/db/versions/10953-redChico/03-hedera.sql b/db/versions/10953-redChico/03-hedera.sql new file mode 100644 index 000000000..3c86fb593 --- /dev/null +++ b/db/versions/10953-redChico/03-hedera.sql @@ -0,0 +1,27 @@ +-- hedera.config +ALTER TABLE hedera.config MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- hedera.imageConfig +ALTER TABLE hedera.imageConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.imageConfig ADD CONSTRAINT imageConfig_check CHECK (id = 1); + +-- hedera.mailConfig +ALTER TABLE hedera.mailConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.mailConfig ADD CONSTRAINT mailConfig_check CHECK (id = 1); + +-- hedera.orderConfig +ALTER TABLE hedera.orderConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE hedera.orderConfig ADD CONSTRAINT orderConfig_check CHECK (id = 1); + +-- hedera.shelfConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE hedera.shelfConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE hedera.shelfConfig ADD CONSTRAINT shelfConfig_check CHECK (id = 1); + +-- hedera.tpvConfig +ALTER TABLE hedera.tpvConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.tpvConfig ADD CONSTRAINT tpvConfig_check CHECK (id = 1); + +-- hedera.tpvImapConfig +ALTER TABLE hedera.tpvImapConfig MODIFY COLUMN id tinyint(3) unsigned NOT NULL; +ALTER TABLE hedera.tpvImapConfig ADD CONSTRAINT tpvImapConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/04-pbx.sql b/db/versions/10953-redChico/04-pbx.sql new file mode 100644 index 000000000..7ca0e6103 --- /dev/null +++ b/db/versions/10953-redChico/04-pbx.sql @@ -0,0 +1,15 @@ +-- pbx.config +ALTER TABLE pbx.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- pbx.followmeConfig +ALTER TABLE pbx.followmeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.followmeConfig ADD CONSTRAINT followmeConfig_check CHECK (id = 1); + +-- pbx.queueConfig +ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); + +-- pbx.sipConfig +ALTER TABLE pbx.sipConfig MODIFY COLUMN id mediumint(8) unsigned NOT NULL; +ALTER TABLE pbx.sipConfig ADD CONSTRAINT sipConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/05-sage.sql b/db/versions/10953-redChico/05-sage.sql new file mode 100644 index 000000000..ee60f5f7d --- /dev/null +++ b/db/versions/10953-redChico/05-sage.sql @@ -0,0 +1,3 @@ +-- sage.config +ALTER TABLE sage.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE sage.config ADD CONSTRAINT config_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/06-salix.sql b/db/versions/10953-redChico/06-salix.sql new file mode 100644 index 000000000..d6a248f0d --- /dev/null +++ b/db/versions/10953-redChico/06-salix.sql @@ -0,0 +1,7 @@ +-- salix.accessTokenConfig +ALTER TABLE salix.accessTokenConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE salix.accessTokenConfig ADD CONSTRAINT accessTokenConfig_check CHECK (id = 1); + +-- salix.printConfig +ALTER TABLE salix.printConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE salix.printConfig ADD CONSTRAINT printConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/06-srt.sql b/db/versions/10953-redChico/06-srt.sql new file mode 100644 index 000000000..53000eee6 --- /dev/null +++ b/db/versions/10953-redChico/06-srt.sql @@ -0,0 +1,3 @@ +-- srt.config +ALTER TABLE srt.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE srt.config ADD CONSTRAINT config_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/07-util.sql b/db/versions/10953-redChico/07-util.sql new file mode 100644 index 000000000..152dce3d1 --- /dev/null +++ b/db/versions/10953-redChico/07-util.sql @@ -0,0 +1,11 @@ +-- util.config +ALTER TABLE util.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- util.notificationConfig +ALTER TABLE util.notificationConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.notificationConfig ADD CONSTRAINT notificationConfig_check CHECK (id = 1); + +-- util.versionConfig +ALTER TABLE util.versionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE util.versionConfig ADD CONSTRAINT versionConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/08-vn.sql b/db/versions/10953-redChico/08-vn.sql new file mode 100644 index 000000000..5d5637651 --- /dev/null +++ b/db/versions/10953-redChico/08-vn.sql @@ -0,0 +1,87 @@ +-- vn.accountingConfig +ALTER TABLE vn.accountingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.accountingConfig ADD CONSTRAINT accountingConfig_check CHECK (id = 1); + +-- vn.auctionConfig +ALTER TABLE vn.auctionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.auctionConfig ADD CONSTRAINT auctionConfig_check CHECK (id = 1); + +-- vn.autoRadioConfig +ALTER TABLE vn.autoRadioConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.autoRadioConfig ADD CONSTRAINT autoRadioConfig_check CHECK (id = 1); + +-- vn.bankEntityConfig +ALTER TABLE vn.bankEntityConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.bankEntityConfig ADD CONSTRAINT bankEntityConfig_check CHECK (id = 1); + +-- vn.bionicConfig +ALTER TABLE vn.bionicConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.bionicConfig ADD CONSTRAINT bionicConfig_check CHECK (id = 1); + +-- vn.buyConfig +ALTER TABLE vn.buyConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.buyConfig ADD CONSTRAINT buyConfig_check CHECK (id = 1); + +-- vn.chatConfig +ALTER TABLE vn.chatConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.chatConfig ADD CONSTRAINT chatConfig_check CHECK (id = 1); + +-- vn.claimConfig +ALTER TABLE vn.claimConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.claimConfig ADD CONSTRAINT claimConfig_check CHECK (id = 1); + +-- vn.clientConfig +ALTER TABLE vn.clientConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.clientConfig ADD CONSTRAINT clientConfig_check CHECK (id = 1); + +-- vn.comparativeAddConfig +ALTER TABLE vn.comparativeAddConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.comparativeAddConfig ADD CONSTRAINT comparativeAddConfig_check CHECK (id = 1); + +-- vn.comparativeConfig +ALTER TABLE vn.comparativeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.comparativeConfig ADD CONSTRAINT comparativeConfig_check CHECK (id = 1); + +-- vn.config +ALTER TABLE vn.config MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.config ADD CONSTRAINT config_check CHECK (id = 1); + +-- vn.conveyorConfig +ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); + +-- vn.deviceProductionConfig +ALTER TABLE vn.deviceProductionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.deviceProductionConfig ADD CONSTRAINT deviceProductionConfig_check CHECK (id = 1); + +-- vn.docuwareConfig +ALTER TABLE vn.docuwareConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.docuwareConfig ADD CONSTRAINT docuwareConfig_check CHECK (id = 1); + +-- vn.floramondoConfig +ALTER TABLE vn.floramondoConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.floramondoConfig ADD CONSTRAINT floramondoConfig_check CHECK (id = 1); + +-- vn.franceExpressConfig +ALTER TABLE vn.franceExpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.franceExpressConfig ADD CONSTRAINT franceExpressConfig_check CHECK (id = 1); + +-- vn.glsConfig +ALTER TABLE vn.glsConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.glsConfig ADD CONSTRAINT glsConfig_check CHECK (id = 1); + +-- vn.greugeConfig +ALTER TABLE vn.greugeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.greugeConfig ADD CONSTRAINT greugeConfig_check CHECK (id = 1); + +-- vn.inventoryConfig +ALTER TABLE vn.inventoryConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.inventoryConfig ADD CONSTRAINT inventoryConfig_check CHECK (id = 1); + +-- vn.invoiceInConfig +ALTER TABLE vn.invoiceInConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.invoiceInConfig ADD CONSTRAINT invoiceInConfig_check CHECK (id = 1); + +-- vn.invoiceOutConfig +ALTER TABLE vn.invoiceOutConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.invoiceOutConfig ADD CONSTRAINT invoiceOutConfig_check CHECK (id = 1); diff --git a/db/versions/10953-redChico/08-vn2.sql b/db/versions/10953-redChico/08-vn2.sql new file mode 100644 index 000000000..42985365e --- /dev/null +++ b/db/versions/10953-redChico/08-vn2.sql @@ -0,0 +1,91 @@ +-- vn.invoiceOutTaxConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE vn.invoiceOutTaxConfig ADD CONSTRAINT invoiceOutTaxConfig_check CHECK (id = 1); + +-- vn.itemConfig +ALTER TABLE vn.itemConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.itemConfig ADD CONSTRAINT itemConfig_check CHECK (id = 1); + +-- vn.machineWorkerConfig +ALTER TABLE vn.machineWorkerConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.machineWorkerConfig ADD CONSTRAINT machineWorkerConfig_check CHECK (id = 1); + +-- vn.mdbConfig +ALTER TABLE vn.mdbConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.mdbConfig ADD CONSTRAINT mdbConfig_check CHECK (id = 1); + +-- vn.mrwConfig +ALTER TABLE vn.mrwConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.mrwConfig ADD CONSTRAINT mrwConfig_check CHECK (id = 1); + +-- vn.osTicketConfig +ALTER TABLE vn.osTicketConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.osTicketConfig ADD CONSTRAINT osTicketConfig_check CHECK (id = 1); + +-- vn.packagingConfig +ALTER TABLE vn.packagingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.packagingConfig ADD CONSTRAINT packagingConfig_check CHECK (id = 1); + +-- vn.packingSiteConfig +ALTER TABLE vn.packingSiteConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.packingSiteConfig ADD CONSTRAINT packingSiteConfig_check CHECK (id = 1); + +-- vn.productionConfig +ALTER TABLE vn.productionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_check CHECK (id = 1); + +-- vn.rateConfig +ALTER TABLE vn.rateConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.rateConfig ADD CONSTRAINT rateConfig_check CHECK (id = 1); + +-- vn.routeConfig +ALTER TABLE vn.routeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.routeConfig ADD CONSTRAINT routeConfig_check CHECK (id = 1); + +-- vn.salespersonConfig +ALTER TABLE vn.salespersonConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.salespersonConfig ADD CONSTRAINT salespersonConfig_check CHECK (id = 1); + +-- vn.sendingConfig +ALTER TABLE vn.sendingConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.sendingConfig ADD CONSTRAINT sendingConfig_check CHECK (id = 1); + +-- vn.smsConfig +ALTER TABLE vn.smsConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.smsConfig ADD CONSTRAINT smsConfig_check CHECK (id = 1); + +-- vn.ticketConfig +ALTER TABLE vn.ticketConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_check CHECK (id = 1); + +-- vn.tillConfig +ALTER TABLE vn.tillConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.tillConfig ADD CONSTRAINT tillConfig_check CHECK (id = 1); + +-- vn.travelConfig +ALTER TABLE vn.travelConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.travelConfig ADD CONSTRAINT travelConfig_check CHECK (id = 1); + +-- vn.viaexpressConfig +ALTER TABLE vn.viaexpressConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.viaexpressConfig ADD CONSTRAINT viaexpressConfig_check CHECK (id = 1); + +-- vn.wagonConfig +ALTER TABLE vn.wagonConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.wagonConfig ADD CONSTRAINT wagonConfig_check CHECK (id = 1); + +-- vn.workerConfig +ALTER TABLE vn.workerConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.workerConfig ADD CONSTRAINT workerConfig_check CHECK (id = 1); + +-- vn.workerTimeControlConfig +ALTER TABLE vn.workerTimeControlConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.workerTimeControlConfig ADD CONSTRAINT workerTimeControlConfig_check CHECK (id = 1); + +-- vn.zipConfig +ALTER TABLE vn.zipConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.zipConfig ADD CONSTRAINT zipConfig_check CHECK (id = 1); + +-- vn.zoneConfig +ALTER TABLE vn.zoneConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +ALTER TABLE vn.zoneConfig ADD CONSTRAINT zoneConfig_check CHECK (id = 1); From 086721157380615d755dc91581671e69562217d2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 15 Mar 2024 12:38:33 +0100 Subject: [PATCH 21/42] refs #6403 Fix model mrwConfig --- back/methods/mrw-config/specs/createShipment.spec.js | 1 + back/models/mrw-config.json | 1 + 2 files changed, 2 insertions(+) diff --git a/back/methods/mrw-config/specs/createShipment.spec.js b/back/methods/mrw-config/specs/createShipment.spec.js index e7bba524a..0f48bc2d3 100644 --- a/back/methods/mrw-config/specs/createShipment.spec.js +++ b/back/methods/mrw-config/specs/createShipment.spec.js @@ -49,6 +49,7 @@ describe('MRWConfig createShipment()', () => { await models.MrwConfig.create( { + 'id': 1, 'url': 'https://url.com', 'user': 'user', 'password': 'password', diff --git a/back/models/mrw-config.json b/back/models/mrw-config.json index f0cf799b1..50cf7e8fc 100644 --- a/back/models/mrw-config.json +++ b/back/models/mrw-config.json @@ -9,6 +9,7 @@ "properties": { "id": { "type": "number", + "id": true, "required": true }, "url": { From 8119106e692624e53807db4c612229b88bd94cb7 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 15 Mar 2024 15:40:54 +0100 Subject: [PATCH 22/42] hotFix: try to debug closeAll --- modules/ticket/back/methods/ticket/closeAll.js | 3 ++- modules/ticket/back/methods/ticket/closure.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 46c45aa92..edd1155ba 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -57,7 +57,8 @@ module.exports = Self => { AND t.refFk IS NULL GROUP BY t.id `, [toDate, toDate]); - + const ticketIds = tickets.map(ticket => ticket.id); + await Self.rawSql(`CALL util.debugAdd('nightInvoicing', ?)`, [ticketIds.join(',')]); await closure(ctx, Self, tickets); await Self.rawSql(` diff --git a/modules/ticket/back/methods/ticket/closure.js b/modules/ticket/back/methods/ticket/closure.js index 1d04679d3..14b040324 100644 --- a/modules/ticket/back/methods/ticket/closure.js +++ b/modules/ticket/back/methods/ticket/closure.js @@ -11,6 +11,7 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) { const failedtickets = []; for (const ticket of tickets) { try { + await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId}); await Self.rawSql(`CALL vn.ticket_closeByTicket(?)`, [ticket.id], {userId}); const [invoiceOut] = await Self.rawSql(` From 4f90fb06d838e65e72ed7deff43d88cd1966a150 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 18 Mar 2024 13:25:23 +0100 Subject: [PATCH 23/42] hotFix(debug) varchar to text --- db/versions/10959-bronzePalmetto/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/10959-bronzePalmetto/00-firstScript.sql diff --git a/db/versions/10959-bronzePalmetto/00-firstScript.sql b/db/versions/10959-bronzePalmetto/00-firstScript.sql new file mode 100644 index 000000000..323238d2e --- /dev/null +++ b/db/versions/10959-bronzePalmetto/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE util.debug MODIFY COLUMN value text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; From 8f54a7f12dc2acba9310f2bc67ccd6fe41777923 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 18 Mar 2024 14:03:16 +0100 Subject: [PATCH 24/42] deliveryDate --- db/dump/fixtures.local.sql | 9 +++++ .../floranet/procedures/deliveryDate_get.sql | 38 ++++++++----------- .../10956-brownBirch/00-firstScript.sql | 12 ++++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 db/versions/10956-brownBirch/00-firstScript.sql diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql index 64d22f480..3714a85fc 100644 --- a/db/dump/fixtures.local.sql +++ b/db/dump/fixtures.local.sql @@ -404,3 +404,12 @@ INSERT INTO floranet.builder( FROM vn.item WHERE name = 'Ramo Terranova'; +INSERT IGNORE INTO floranet.addressPostCode (id, addressFk, postCode, hoursInAdvance, dayOfWeek, deliveryCost) + VALUES (1, 4, '46680', 48, 2, 6.00), + (5, 4, '46680', 24, 3, 6.00), + (6, 4, '46680', 24, 4, 6.00), + (7, 4, '46680', 24, 5, 6.00), + (8, 4, '46680', 24, 6, 0.00), + (9, 4, '46680', 24, 7, 20.00), + (2, 3, '46680', 24, 2, 9.25), + (3, 3, '46440', 24, 3, 0.00); \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 06a8ae1ad..29751ebe4 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -2,34 +2,28 @@ DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.deliveryDate_get(vPostalCode VARCHAR(15)) -READS SQL DATA +CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) + READS SQL DATA BEGIN /** - * Returns available dates for this postalCode + * Returns available dates for this postalCode, in the next seven days * * @param vPostalCode Delivery address postal code */ - CREATE OR REPLACE TEMPORARY TABLE tmp.deliveryDate - (dated DATE PRIMARY KEY) - ENGINE = MEMORY; + DECLARE vCurrentDayOfWeek INT; - IF vPostalCode != "00000" THEN - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 1 DAY; + SET vCurrentDayOfWeek = DAYOFWEEK(NOW()); - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 2 DAY; - - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 4 DAY; - - INSERT INTO tmp.deliveryDate - SET dated = CURDATE() + INTERVAL 7 DAY; - END IF; - - SELECT * FROM tmp.deliveryDate; - - DROP TEMPORARY TABLE tmp.deliveryDate; + SELECT DISTINCT nextDay + FROM ( + SELECT CURDATE() + INTERVAL IF( + apc.dayOfWeek >= vCurrentDayOfWeek, + apc.dayOfWeek - vCurrentDayOfWeek, + 7 - apc.dayOfWeek + ) DAY nextDay, + NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime + FROM addressPostCode apc + WHERE apc.postCode = vPostalCode + HAVING nextDay > minDeliveryTime) sub; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10956-brownBirch/00-firstScript.sql b/db/versions/10956-brownBirch/00-firstScript.sql new file mode 100644 index 000000000..bcd15432c --- /dev/null +++ b/db/versions/10956-brownBirch/00-firstScript.sql @@ -0,0 +1,12 @@ +CREATE TABLE floranet.`addressPostCode` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `addressFk` int(11) NOT NULL, + `postCode` varchar(30) NOT NULL, + `hoursInAdvance` int(10) unsigned NOT NULL DEFAULT 24, + `dayOfWeek` int(10) unsigned NOT NULL, + `deliveryCost` decimal(10,2) NOT NULL DEFAULT 0.00, + PRIMARY KEY (`id`), + UNIQUE KEY `addressPostCode_unique` (`postCode`,`addressFk`,`dayOfWeek`), + KEY `addressPostCode_address_FK` (`addressFk`), + CONSTRAINT `addressPostCode_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Client''s address registered for floranet network'; \ No newline at end of file From b3271209328489f3223f6367a33e53552231c3b0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 07:39:38 +0100 Subject: [PATCH 25/42] fix: refs #6232 Comment queueConfig lines --- db/versions/10953-redChico/04-pbx.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/10953-redChico/04-pbx.sql b/db/versions/10953-redChico/04-pbx.sql index 7ca0e6103..49f4172c4 100644 --- a/db/versions/10953-redChico/04-pbx.sql +++ b/db/versions/10953-redChico/04-pbx.sql @@ -6,9 +6,9 @@ ALTER TABLE pbx.config ADD CONSTRAINT config_check CHECK (id = 1); ALTER TABLE pbx.followmeConfig MODIFY COLUMN id int(10) unsigned NOT NULL; ALTER TABLE pbx.followmeConfig ADD CONSTRAINT followmeConfig_check CHECK (id = 1); --- pbx.queueConfig -ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; -ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); +-- pbx.queueConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE pbx.queueConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE pbx.queueConfig ADD CONSTRAINT queueConfig_check CHECK (id = 1); -- pbx.sipConfig ALTER TABLE pbx.sipConfig MODIFY COLUMN id mediumint(8) unsigned NOT NULL; From 397b49db915d2062b2c480ecc4ae7e61c316468a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 08:02:11 +0100 Subject: [PATCH 26/42] fix: refs #6232 Comment conveyorConfig lines --- db/versions/10953-redChico/08-vn.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/10953-redChico/08-vn.sql b/db/versions/10953-redChico/08-vn.sql index 5d5637651..14bd3b13f 100644 --- a/db/versions/10953-redChico/08-vn.sql +++ b/db/versions/10953-redChico/08-vn.sql @@ -46,9 +46,9 @@ ALTER TABLE vn.comparativeConfig ADD CONSTRAINT comparativeConfig_check CHECK (i ALTER TABLE vn.config MODIFY COLUMN id int(10) unsigned NOT NULL; ALTER TABLE vn.config ADD CONSTRAINT config_check CHECK (id = 1); --- vn.conveyorConfig -ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; -ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); +-- vn.conveyorConfig (Tiene más de 1 registro en producción) +-- ALTER TABLE vn.conveyorConfig MODIFY COLUMN id int(10) unsigned NOT NULL; +-- ALTER TABLE vn.conveyorConfig ADD CONSTRAINT conveyorConfig_check CHECK (id = 1); -- vn.deviceProductionConfig ALTER TABLE vn.deviceProductionConfig MODIFY COLUMN id int(10) unsigned NOT NULL; From 7895a51e3364d7a154bc0cb1db8d2a9ccf0b44a7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 20 Mar 2024 12:15:41 +0100 Subject: [PATCH 27/42] hotFix(closeAll): fix debug --- modules/ticket/back/methods/ticket/closeAll.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index edd1155ba..11900bada 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -58,7 +58,11 @@ module.exports = Self => { GROUP BY t.id `, [toDate, toDate]); const ticketIds = tickets.map(ticket => ticket.id); - await Self.rawSql(`CALL util.debugAdd('nightInvoicing', ?)`, [ticketIds.join(',')]); + await Self.rawSql(` + INSERT INTO util.debug (variable, value) + VALUES ('nightInvoicing', ?) + `, [ticketIds.join(',')]); + await closure(ctx, Self, tickets); await Self.rawSql(` From d53a053ccb9aed3e50f916a63daf77c1b9f39419 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 20 Mar 2024 13:07:02 +0100 Subject: [PATCH 28/42] refactor: refs #6923 Deteted procs --- .../vn2008/procedures/add_awb_component.sql | 61 ------------------- .../vn2008/procedures/agencyModeImbalance.sql | 50 --------------- 2 files changed, 111 deletions(-) delete mode 100644 db/routines/vn2008/procedures/add_awb_component.sql delete mode 100644 db/routines/vn2008/procedures/agencyModeImbalance.sql diff --git a/db/routines/vn2008/procedures/add_awb_component.sql b/db/routines/vn2008/procedures/add_awb_component.sql deleted file mode 100644 index e75290b4b..000000000 --- a/db/routines/vn2008/procedures/add_awb_component.sql +++ /dev/null @@ -1,61 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`add_awb_component`(IN vAwbFk SMALLINT) -BEGIN - - DECLARE vShipped DATE; - DECLARE vHasStems BOOLEAN; - - SELECT t.shipped, IF(a.stems, TRUE, FALSE) - INTO vShipped, vHasStems - FROM vn.travel t - JOIN vn.awb a ON a.id = t.awbFk - WHERE awbFk = vAwbFk - LIMIT 1; - - INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda) - SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda - FROM ( - SELECT a.id, - IFNULL(act.carguera_id, - CASE awb_role_id - WHEN 1 THEN a.carguera_id - WHEN 2 THEN a.transitario_id - WHEN 3 THEN f.airline_id - END - ) Id_Proveedor, - act.awb_component_type_id, - act.awb_role_id, - act.awb_unit_id, - value * - CASE awb_unit_id - WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value) - WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value) - WHEN '100GW' THEN peso/100 - WHEN 'AWB' THEN 1 -- No action - WHEN 'FB' THEN hb/2 - WHEN 'GW' THEN peso - WHEN 'TW' THEN GREATEST(peso,volume_weight) - WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10) - END value1, - value, - act.Id_Moneda, - act.min_value, - act.max_value - FROM awb a - JOIN flight f ON f.flight_id = a.flight_id - LEFT JOIN awb_component_template act ON - ((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1) - OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2) - OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3) - OR (awb_role_id = 4)) - AND IFNULL(act.airport_out, f.airport_out) = f.airport_out - AND IFNULL(act.airport_in, f.airport_in) = f.airport_in - AND IFNULL(act.airline_id, f.airline_id) = f.airline_id - AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1) - JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id - WHERE a.id = vAwbFk AND Fecha <= vShipped - AND (vHasStems = TRUE OR acty.hasStems) - ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000 - ) t; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/agencyModeImbalance.sql b/db/routines/vn2008/procedures/agencyModeImbalance.sql deleted file mode 100644 index 89706f0d2..000000000 --- a/db/routines/vn2008/procedures/agencyModeImbalance.sql +++ /dev/null @@ -1,50 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencyModeImbalance`(vStarted DATE, vEnded DATE) -BEGIN -/** - * Devuelve el valor de los precios teorico, practico de las agencias - * y si ademas es de mrw lo compara con su fichero previamente procesado - * - * @param vEktFk Identificador de edi.ekt - */ - DECLARE vEndedDayEnd DATETIME; - - SET vEndedDayEnd = util.dayEnd(vEnded); - - SELECT t.id ticketFk,t.addressFk, - CAST(v.amount AS DECIMAL (10,2)) AS VN, - CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer, - CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice, - CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference, - CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico, - CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge, - t.packages, t.clientFk, - t.zoneFk, a.provinceFk, mrwCount - FROM vn.ticket t - LEFT JOIN - (SELECT ticketFk, SUM(amount) amount, fc.shipped - FROM vn.sale_freightComponent fc - JOIN vn.ticket t ON t.id = fc.ticketFk - JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk - WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd - GROUP BY ticketFk) v ON t.id = v.ticketFk - LEFT JOIN (SELECT t.id, - SUM(t.zonePrice) shipping_charge, - SUM(IFNULL(aex.price,0)) extraCharge - FROM vn.ticket t - LEFT JOIN vn.expedition e ON e.ticketFk = t.id - LEFT JOIN vn.packaging p ON p.id = e.packagingFk - JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk - JOIN vn.agencyMode am ON am.id = amc.agencyModeFk - LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk - WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd - GROUP BY t.id - ) e ON t.id = e.id - LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount - FROM vn.mrw - GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id - JOIN vn.address a ON a.id = t.addressFk - JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk - WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd; -END$$ -DELIMITER ; From 5a45cf7ea2d47a8177edb4abbadb794a29b441ff Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 20 Mar 2024 13:39:26 +0100 Subject: [PATCH 29/42] refs #6842 remove sage --- db/routines/vn2008/views/empresa.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn2008/views/empresa.sql b/db/routines/vn2008/views/empresa.sql index 3b43ee574..8c80a06e8 100644 --- a/db/routines/vn2008/views/empresa.sql +++ b/db/routines/vn2008/views/empresa.sql @@ -5,7 +5,6 @@ AS SELECT `c`.`id` AS `id`, `c`.`code` AS `abbreviation`, `c`.`supplierAccountFk` AS `Id_Proveedores_account`, `c`.`workerManagerFk` AS `gerente_id`, - `c`.`sage200Company` AS `digito_factura`, `c`.`phytosanitary` AS `phytosanitary`, `c`.`companyCode` AS `CodigoEmpresa`, `c`.`companyGroupFk` AS `empresa_grupo`, From f7b458d3683cd4a7bfa0c9ddd8431623252406b6 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 20 Mar 2024 20:54:24 +0100 Subject: [PATCH 30/42] feat: refs #6302 delete after add to turn --- db/dump/fixtures.before.sql | 4 ++-- e2e/paths/05-ticket/09_weekly.spec.js | 20 +++++++++---------- modules/ticket/back/models/ticket-weekly.js | 8 ++++++++ modules/ticket/front/descriptor-menu/index.js | 3 ++- .../front/descriptor-menu/locale/es.yml | 1 + 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 795ffb25f..4e01532e2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -760,8 +760,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL); - + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), + (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES (1, 11, 1, 'ready'), diff --git a/e2e/paths/05-ticket/09_weekly.spec.js b/e2e/paths/05-ticket/09_weekly.spec.js index 74febfd01..20cfa0d13 100644 --- a/e2e/paths/05-ticket/09_weekly.spec.js +++ b/e2e/paths/05-ticket/09_weekly.spec.js @@ -24,7 +24,7 @@ describe('Ticket descriptor path', () => { it('should go back to the ticket index then search and access a ticket summary', async() => { await page.accessToSection('ticket.index'); - await page.accessToSearchResult('11'); + await page.accessToSearchResult('33'); }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { @@ -33,7 +33,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.thursdayButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Data saved!'); + expect(message.text).toContain('Current ticket deleted and added to shift'); }); it('should again click on the Tickets button of the top bar menu', async() => { @@ -43,7 +43,7 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should confirm the ticket 11 was added to thursday', async() => { + it('should confirm the ticket 33 was added to thursday', async() => { await page.accessToSection('ticket.weekly.index'); const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value'); @@ -57,8 +57,8 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should now search for the ticket 11', async() => { - await page.accessToSearchResult('11'); + it('should now search for the ticket 33', async() => { + await page.accessToSearchResult('33'); await page.waitForState('ticket.card.summary'); }); @@ -68,7 +68,7 @@ describe('Ticket descriptor path', () => { await page.waitToClick(selectors.ticketDescriptor.saturdayButton); const message = await page.waitForSnackbar(); - expect(message.text).toContain('Data saved!'); + expect(message.text).toContain('Current ticket deleted and added to shift'); }); it('should click on the Tickets button of the top bar menu once again', async() => { @@ -78,7 +78,7 @@ describe('Ticket descriptor path', () => { await page.waitForState('ticket.index'); }); - it('should confirm the ticket 11 was added on saturday', async() => { + it('should confirm the ticket 33 was added on saturday', async() => { await page.accessToSection('ticket.weekly.index'); await page.waitForTimeout(5000); @@ -87,14 +87,14 @@ describe('Ticket descriptor path', () => { expect(result).toEqual('Saturday'); }); - it('should now search for the weekly ticket 11', async() => { - await page.doSearch('11'); + it('should now search for the weekly ticket 33', async() => { + await page.doSearch('33'); const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); expect(nResults).toEqual(2); }); - it('should delete the weekly ticket 11', async() => { + it('should delete the weekly ticket 33', async() => { await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon); await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn); const message = await page.waitForSnackbar(); diff --git a/modules/ticket/back/models/ticket-weekly.js b/modules/ticket/back/models/ticket-weekly.js index 8db53b283..b6b1d586c 100644 --- a/modules/ticket/back/models/ticket-weekly.js +++ b/modules/ticket/back/models/ticket-weekly.js @@ -1,4 +1,5 @@ const UserError = require('vn-loopback/util/user-error'); +const LoopBackContext = require('loopback-context'); module.exports = Self => { require('../methods/ticket-weekly/filter')(Self); @@ -8,4 +9,11 @@ module.exports = Self => { return new UserError(`This ticket is already on weekly tickets`); return err; }); + + Self.observe('after save', async ctx => { + const loopBackContext = LoopBackContext.getCurrentContext(); + const httpCtx = {req: loopBackContext.active}; + const httpRequest = httpCtx.req.http; + await Self.app.models.Ticket.setDeleted(httpRequest, ctx.instance.ticketFk, ctx.options); + }); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index d2dd13f73..52cac141c 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -147,7 +147,8 @@ class Controller extends Section { return this.$http.patch(`TicketWeeklies`, params) .then(() => { this.$.addTurn.hide(); - this.vnApp.showSuccess(this.$t('Data saved!')); + this.vnApp.showSuccess(this.$t('Current ticket deleted and added to shift')); + this.reload(); }); } diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index 111fc2702..008c9a358 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -28,3 +28,4 @@ Create a single ticket with all the content of the current ticket: Crea un ticke Set ticket weight: Establecer peso al ticket Ticket weight: Peso del ticket This address has incoterms, you should set the weight before invoice it: Este consigatario tiene incoterms, deberías establecer el peso antes de facturar +Current ticket deleted and added to shift: Ticket actual borrado y añadido a turno \ No newline at end of file From da8fbb5a926d17c78b504d7104af07ef4abdde2c Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 20 Mar 2024 21:14:01 +0100 Subject: [PATCH 31/42] fix: refs #6302 spec --- modules/ticket/back/methods/ticket/specs/filter.spec.js | 2 +- modules/ticket/front/descriptor-menu/index.spec.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index c1d3f1a9c..e495a41f5 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -68,7 +68,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(7); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 80ad9a33a..94a991db8 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -41,6 +41,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { })); describe('addTurn()', () => { + pending('refs #6302'); it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => { controller.$.addTurn = {hide: () => {}}; jest.spyOn(controller.$.addTurn, 'hide'); From de83cef68cf16c55bd9767cfa0dfd21b239f059f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 08:01:27 +0100 Subject: [PATCH 32/42] build: refs #5846 HOTFIX Myt updated --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e897823d..aa410f8df 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.7.4", "@babel/preset-env": "^7.11.0", "@babel/register": "^7.7.7", - "@verdnatura/myt": "^1.6.8", + "@verdnatura/myt": "^1.6.9", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", From bbbd212547898dc677cae5c0531e102a2e0a4f16 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 08:14:59 +0100 Subject: [PATCH 33/42] build: refs #5846 HOTFIX Myt updated --- pnpm-lock.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b1f68378d..3f0473929 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,8 +131,8 @@ devDependencies: specifier: ^7.7.7 version: 7.23.7(@babel/core@7.23.9) '@verdnatura/myt': - specifier: ^1.6.8 - version: 1.6.8 + specifier: ^1.6.9 + version: 1.6.9 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2633,8 +2633,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.8: - resolution: {integrity: sha512-jpadr6yAR9TQXPv+has5yOYAolR/YEzsxbLgMR7BoDrpLyVFLHJEy4Dfe+Hy11r3AmxCB/8lWM+La1YGvXMWOA==} + /@verdnatura/myt@1.6.9: + resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 @@ -4886,6 +4886,7 @@ packages: /deep-extend@0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} + requiresBuild: true /deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -12714,6 +12715,7 @@ packages: /strip-json-comments@2.0.1: resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} engines: {node: '>=0.10.0'} + requiresBuild: true /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} From 1cd495df06984f6d43d5bd60f96cc765bd06649b Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 09:25:33 +0100 Subject: [PATCH 34/42] fix: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 3b5ce5247..8c4015bc3 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -11,7 +11,7 @@ BEGIN */ DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; - DECLARE vExpenseFk INT; + DECLARE vExpenseFk VARCHAR(10); SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr From d0067c80967b9a8b20b0cb696922b89869fd756f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 11:30:10 +0100 Subject: [PATCH 35/42] ticket #167473 Hotfix --- db/routines/bs/procedures/ventas_contables_add.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 12b2738f3..9e2b75f6d 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -23,7 +23,7 @@ BEGIN ENGINE = MEMORY SELECT Id_Ticket FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + JOIN vn.invoiceOut io ON io.`ref` = t.Factura WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -47,12 +47,7 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk - + IF(e.empresa_grupo = e2.empresa_grupo - ,1 - ,IF(e2.empresa_grupo,2,0) - ) * 100000 - + tp.reino_id * 1000 as Gasto + , a.expenseFk gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna From 535dd406250ddd6b0764142e6a7681b9d51e8b6d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:06:59 +0100 Subject: [PATCH 36/42] fix: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 3b5ce5247..40fd98378 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -11,18 +11,20 @@ BEGIN */ DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; - DECLARE vExpenseFk INT; + DECLARE vCurrencyFk INT; + DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated) INTO vDated + SELECT MAX(rr.dated), ii.currencyFk INTO vDated, vCurrencyFk FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk WHERE rr.dated <= ii.issued AND rr.currencyFk = ii.currencyFk; - IF vDated THEN + IF vDated AND vCurrencyFk THEN SELECT `value` INTO vRate FROM referenceRate - WHERE dated = vDated; + WHERE dated = vDated + AND currencyFk = vCurrencyFk; END IF; DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; From ee67820c20b2257c2358b81607b0474470c96168 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:14:48 +0100 Subject: [PATCH 37/42] refactor: refs #7018 Fix invoiceInTax_recalc --- db/routines/vn/procedures/invoiceInTax_recalc.sql | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_recalc.sql b/db/routines/vn/procedures/invoiceInTax_recalc.sql index 40fd98378..4e20b01d3 100644 --- a/db/routines/vn/procedures/invoiceInTax_recalc.sql +++ b/db/routines/vn/procedures/invoiceInTax_recalc.sql @@ -10,22 +10,15 @@ BEGIN * @param vInvoiceInFk Id de factura recibida */ DECLARE vRate DOUBLE DEFAULT 1; - DECLARE vDated DATE; - DECLARE vCurrencyFk INT; DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated), ii.currencyFk INTO vDated, vCurrencyFk + SELECT `value` INTO vRate FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk WHERE rr.dated <= ii.issued - AND rr.currencyFk = ii.currencyFk; - - IF vDated AND vCurrencyFk THEN - SELECT `value` INTO vRate - FROM referenceRate - WHERE dated = vDated - AND currencyFk = vCurrencyFk; - END IF; + AND rr.currencyFk = ii.currencyFk + ORDER BY dated DESC + LIMIT 1; DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; From ece94c2bd124a4b7668550a5dd6f7043bdfa702c Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 21 Mar 2024 12:39:39 +0100 Subject: [PATCH 38/42] ref #5034 remove e2e --- e2e/paths/14-account/05_connections.spec.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js index 89b286101..49d5f612d 100644 --- a/e2e/paths/14-account/05_connections.spec.js +++ b/e2e/paths/14-account/05_connections.spec.js @@ -22,12 +22,4 @@ describe('Account Connections path', () => { expect(firstResult).toContain(account); }); - - it('should kill this connection and then get redirected to the login page', async() => { - await page.waitToClick(selectors.accountConnections.deleteFirstConnection); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Your session has expired, please login again'); - }); }); From 2b26153bfa597fcd84f200a292f03aa2daad672c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 21 Mar 2024 12:52:04 +0100 Subject: [PATCH 39/42] refactor: refs #7018 Requested changes --- db/routines/bs/procedures/ventas_contables_add.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 9e2b75f6d..66c012a19 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -47,7 +47,12 @@ BEGIN , tp.reino_id , a.tipo_id , t.empresa_id - , a.expenseFk gasto + , a.expenseFk + + IF(e.empresa_grupo = e2.empresa_grupo + ,1 + ,IF(e2.empresa_grupo,2,0) + ) * 100000 + + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna From 8fd7792e7cdfd75b941be28f8023545d2ecc9ad2 Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 22 Mar 2024 11:05:48 +0100 Subject: [PATCH 40/42] gitignore --- db/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.gitignore b/db/.gitignore index 231f0dfe0..54ed9df77 100644 --- a/db/.gitignore +++ b/db/.gitignore @@ -4,7 +4,7 @@ remotes/*.ini !remotes/local.ini !remotes/docker.ini dump/.changes -#dump/fixtures.local.sql +dump/fixtures.local.sql .dBeaver .idea .project From 214aff403a187bd7327ea206203dd88f466f6c74 Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 22 Mar 2024 11:09:49 +0100 Subject: [PATCH 41/42] delete fixtures local --- db/dump/fixtures.local.sql | 415 ------------------------------------- 1 file changed, 415 deletions(-) delete mode 100644 db/dump/fixtures.local.sql diff --git a/db/dump/fixtures.local.sql b/db/dump/fixtures.local.sql deleted file mode 100644 index 3714a85fc..000000000 --- a/db/dump/fixtures.local.sql +++ /dev/null @@ -1,415 +0,0 @@ --- XXX: floranet - -INSERT IGNORE INTO vn.intrastat(id, description, taxClassFk, taxCodeFk) -VALUES(6031970, 'Flores y capullos frescos (Otras: ramos, coronas)', 1, 63); - - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNR', 'Floranet Ramos', 1, 1); - -INSERT IGNORE INTO vn.itemType (code, name, categoryFk, workerFk) - VALUES('FNP', 'Floranet Plantas', 1, 1); - --- Generación de items -SELECT id - INTO @FNR - FROM vn.itemType - WHERE code = 'FNR'; - -SELECT id - INTO @FNP - FROM vn.itemType - WHERE code = 'FNP'; - -DELETE - FROM vn.item - WHERE typeFk IN (@FNR,@FNP); - -INSERT INTO vn.item - ( - id, - name, - longName, - `size`, - originFk, - intrastatFk, - typeFk, - inkFk, - image, - description - ) - VALUES - ( - 147791, - @r := 'Ramo Terranova', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin ORDER BY RAND() LIMIT 1), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147791', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar ', - 'esta composición: brásicas, flor de cera, astrantia, espigas, lisiantum, ', - 'paniculata eucaliptus.') - ), - ( - 147792, - @r := 'Ramo Tasmania', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147792', - CONCAT('La elegancia de este ramo es por la elección de todas las flores que lo componen: ', - 'eringium, verdes variados, rosas proteas, margaritas, astrantia, esta selección de ', - 'flores será un acierto seguro para hacer un regalo muy especial.') - ), - ( - 147793, - @r := 'Ramo Pasion', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147793', - CONCAT('La unión de las rosas rojas con el lilium rosa hace de este ramo uno de ', - 'los más especiales , el juego de las dos tonalidades con los diferentes verdes ', - 'que cuidadosamente selecionamos para darle el toque final a la composicion hace ', - 'que este ramo sea al mismo tiempo elegante y atrevido, para amantes de lo inesperado ', - 'que quieren decorar alguna estancia de su hogar o hacer un ragalo muy especial') - ), - ( - 147794, - @r := 'Ramo Florencia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147794', - CONCAT('Este ramo evoca los colores del atardecer en Florencia, las rosas ramificadas ', - 'de pitimini con diferentes tonalidades y la paniculata nos transpotan al ambiente ', - 'sofisticado del norte de Italia y la frescura de los verdes variados nos recuerda ', - 'a la campiña italiana .Este ramo es ideal para regalar pensando en alguien muy especial.') - ), - ( - 147795, - @r := 'Ramo Atardecer', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink WHERE name = 'Yellow'), - '147795', - CONCAT('Las rosas amarillas simbolizan la alegría de vivir, la calidez ,el ', - 'optimismo y la energía, por eso son el regalo perfecto para una ocasión muy ', - 'especial o para celebrar la alegría de una amistad o de un encuentro, a estas ', - 'preciosas rosas les añadimos un toque desenfadado a través de los verdes ', - 'variados que unidos a la belleza de la rosa que seguro serán una apuesta segura.') - ), - ( - 147796, - @r := 'Ramo Arcoíris', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147796', - CONCAT('Llega la primavera a tu casa con el ramo Arco Iris , conseguirás iluminar ', - 'cualquier estancia gracias a la combinacón de las gerberas holandesas de gran ', - 'tamaño con colores muy vivos que a su vez contrastan a la perfección con las ', - 'margaritas coconut y el estatice variado, todo ello acompañado de verdes entre ', - 'los que destaca el ruscus danae , para dulcificar la explosión de color , ', - 'añadimos paniculata , una flor sencilla pero que aporta gran armonía al ramo') - ), - ( - 147797, - @r := 'Ramo Provenza', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147797', - CONCAT('La delicada composición de este ramo escogida de forma minuciosa hecho ', - 'con liliums rosa, lisiantum blanco y rosas de color rosa todo ello unificado ', - 'con una selección de maravillosos verdes variados, hacen que esta combinación ', - 'sea muy especial para decorar cualquier estancia de tu casa a la que aportará una luz especial.') - ), - ( - 147798, - @r := 'Ramo Alegria', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147798', - CONCAT('Hemos elegido el nombre de Alegría para este ramo ya que sus intensos ', - 'y variados colores nos producen esa sensación, la combinación de rosas blancas ', - ', alstroemeria rosa unida a la paniculata tambien de color rosa y a la sutileza ', - 'de la combinación de verdes variados, hace de este ramo una opción perfecta de ', - 'regalo que a todo el mundo le gusta por su armoniosa combinacion de colores.') - ), - ( - 147799, - @r := 'Planta Orquídeas ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147799', - CONCAT('Elegimos personalmente en nuestra tienda dos plantas de orquídeas ', - 'con las mejores características combinadas con diferentes elementos de ', - 'decoración consiguiendo una composición ideal para cualquier ambiente.El ', - 'recipiente de cerámica se puede utilizar para múltiples funciones y sacar ', - 'de el las dos plantas de orquídeas para colocarlas en dos puntos diferentes ', - 'de nuestro hogar, ya que se respeta siempre las macetas originales de cada orquídea') - ), - ( - 147800, - @r := 'Planta Kentia', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147800', - CONCAT('La Kentia es una de las plantas más decorativas debido al porte que ', - 'le otorgan sus largas finas hojas arqueadas, ideal para un regalo que dejará ', - 'sin palabras a quien lo reciba o para decorar una estancia de tu hogar, ', - 'desde un espacio super moderno hasta el ambiente más clásico. Nuestras Kentias ', - 'proceden de uno de los mejores productores de kentias del mundo, con el añadido ', - 'de ser un producto nacional producido en Canarias de una calidad extrema.') - ), - ( - 147801, - @r := 'Planta Calathea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147801', - CONCAT('Esta planta originaria de América tropical, principalmente de Brasil y Perú ', - ', son plantas ideales para embellecer el interior de una estancia . Debido a su ', - 'llamativo y original colorido, tambien es un regalo perfecto para ', - 'cualquier compromiso que tengamos .') - ), - ( - 147802, - @r := 'Planta Anthurium ', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNP, - (SELECT id FROM vn.ink WHERE name = 'Red'), - '147802', - CONCAT('Nos encanta el color rojo de sus flores .Esta planta original de ', - 'Costa Rica ,proviene de las zonas tropicales de America Central y del Sur, ', - 'su llamativo color alegrará cualquier celebración') - ), - ( - 147803, - @r := 'Ramo Mindanao', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147803', - CONCAT('La combinación de rosas ramificadas amarillas, las hortensias blancas, ', - 'el estatice, el limonium Tanacetum y los verdes variados hace de este ramo uno ', - 'de los que más gustan tanto si es para regalar como para decorar un rincón de tu casa.') - ), - ( - 147804, - @r := 'Ramo Guinea', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147804', - CONCAT('Hemos elegido una selección de flores muy especiales para realizar esta composición:', - ' brásicas, flor de cera, astrantia, espigas, lisiantum, paniculata eucaliptus.') - ), - ( - 147805, - @r := 'Ramo Eterno', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147805', - CONCAT('La perfecta combinación de los diferentes tonos de estatice y el eucaliptus ', - 'cinerea hacen de este ramo un recuerdo inolvidable ya que ambos materiales son de ', - 'larga duración por lo que podrás conservar tu ramo junto con las bonitas vivencias ', - 'de ese día durante mucho tiempo, además le añadimos un toque especial que le dan ', - 'las raices las cuales combinan con los tonos del ramo, unas bonitas cintas del colores ', - 'rematan el acabado del ramo. Este ramo se puede secar y mantenerse en perfecto estado.') - ), - ( - 147806, - @r := 'Ramo Cielo', - @r, - 20 + CEIL(RAND() * 55), - (SELECT id FROM vn.origin WHERE code = 'SPA'), - 6031970, - @FNR, - (SELECT id FROM vn.ink ORDER BY RAND() LIMIT 1), - '147806', - CONCAT('Las hortensias son unas de las flores más elegantes que existen y ', - 'la combinación que proponemos para este ramo te resultará de lo más armoniosa ', - ', ya que intercalamos flores de mayor tamaño como las hortensias azules y ', - 'blancas junto con flores más pequeñas y delicadas como el estatice , todo ello', - ' combinado con el eucaliptus cinerea que te aportará un sueve aroma en toda ', - 'la estancia, el atado del ramo es de rafia natural, siguiendo la tonalidad ', - 'clara de todo el conjunto. ') - ); - - -- Ramo Terranova: 1er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Rosa roja', - @r, - 60, - 1, - 'RED', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 12 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - -- Ramo Terranova: 2º elemento - -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Hoja de helecho', - @r, - 60, - 1, - 'BAS', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 4 - FROM vn.item - WHERE name = 'Ramo Terranova'; - - - -- Ramo Terranova: 3er elemento -INSERT INTO vn.item( - name, - longName, - `size`, - stems, - inkFk, - intrastatFk, - typeFk, - originFk) - SELECT - @r:= 'Paniculata', - @r, - 60, - 1, - 'SLV', - 6031970, - id, - 1 - FROM vn.itemType - WHERE code LIKE 'FNE'; - -SELECT LAST_INSERT_ID() INTO @itemFk; - -INSERT INTO floranet.`element` - SET itemFk = @itemFk; - -INSERT INTO floranet.builder( - itemFk, - elementFk, - quantity) - SELECT - id, - @itemFk, - 5 - FROM vn.item - WHERE name = 'Ramo Terranova'; - -INSERT IGNORE INTO floranet.addressPostCode (id, addressFk, postCode, hoursInAdvance, dayOfWeek, deliveryCost) - VALUES (1, 4, '46680', 48, 2, 6.00), - (5, 4, '46680', 24, 3, 6.00), - (6, 4, '46680', 24, 4, 6.00), - (7, 4, '46680', 24, 5, 6.00), - (8, 4, '46680', 24, 6, 0.00), - (9, 4, '46680', 24, 7, 20.00), - (2, 3, '46680', 24, 2, 9.25), - (3, 3, '46440', 24, 3, 0.00); \ No newline at end of file From 8a51df2fe59561b45560ea2e23f4127770822af6 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 22 Mar 2024 12:28:23 +0100 Subject: [PATCH 42/42] refs #6498 Delete multipleInventoryHistory --- .../procedures/multipleInventoryHistory.sql | 158 ------------------ 1 file changed, 158 deletions(-) delete mode 100644 db/routines/vn/procedures/multipleInventoryHistory.sql diff --git a/db/routines/vn/procedures/multipleInventoryHistory.sql b/db/routines/vn/procedures/multipleInventoryHistory.sql deleted file mode 100644 index dc19e615a..000000000 --- a/db/routines/vn/procedures/multipleInventoryHistory.sql +++ /dev/null @@ -1,158 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`( - vItemFk INT -) -BEGIN -/** -* Calcula y proporciona un historial de inventario detallado -* para un artículo dividiendo la información -* por almacén. -* -* @param vItemFk Artículo -*/ - DECLARE vDateInventory DATETIME; - - SELECT inventoried INTO vDateInventory FROM config; - - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1; - - CREATE TEMPORARY TABLE tMultipleHistory1 - SELECT DATE(`date`) `date`, - input, - `output`, - ok, - reference, - history.id, - warehouse, - `name` warehouseName - FROM ( - SELECT tr.landed `date`, - c.quantity input, - NULL `output`, - tr.warehouseInFk warehouse, - tr.isReceived ok, - e.invoiceNumber reference, - e.id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity - UNION ALL - SELECT tr.shipped, - NULL, - c.quantity, - tr.warehouseOutFk, - tr.isDelivered, - e.invoiceNumber, - e.id - FROM buy c - JOIN `entry` e ON e.id = c.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.shipped >= vDateInventory - AND c.itemFk = vItemFk - AND NOT e.isRaid - AND c.quantity - UNION ALL - SELECT t.shipped, - NULL, - m.quantity, - t.warehouseFk, - (m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL), - t.refFk, - t.id - FROM sale m - JOIN ticket t ON t.id = m.ticketFk - WHERE t.shipped >= vDateInventory - AND m.itemFk = vItemFk - ) history - JOIN warehouse ON warehouse.id = history.warehouse - ORDER BY `date`, input DESC, ok DESC; - - DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3, - tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8; - CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19; - CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7; - CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60; - CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5; - CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17; - CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37; - CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55; - - SELECT * - FROM ( - SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid, - NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid, - NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid, - NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid, - NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid, - NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid, - NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid - FROM tMultipleHistory2 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory3 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory4 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory5 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory6 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id, - NULL, NULL, NULL, NULL, NULL - FROM tMultipleHistory7 - UNION ALL - SELECT `date`, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, - input, `output`, ok, reference, id - FROM tMultipleHistory8 - ) sub - ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL, - MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL; -END$$ -DELIMITER ; \ No newline at end of file