From 80ecd698f8011c506b467f255ab285c8a42ba466 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 08:23:58 +0100 Subject: [PATCH 1/9] refactor: refs #6499 Migrated procs to vn --- .../procedures/balanceNestTree_addChild.sql} | 33 +++--- .../procedures/balanceNestTree_delete.sql} | 35 +++--- .../vn/procedures/balanceNestTree_move.sql | 111 ++++++++++++++++++ db/routines/vn/procedures/pay.sql | 68 +++++++++++ db/routines/vn2008/procedures/nest_move.sql | 108 ----------------- db/routines/vn2008/procedures/pay.sql | 67 ----------- 6 files changed, 210 insertions(+), 212 deletions(-) rename db/routines/{vn2008/procedures/nest_child_add.sql => vn/procedures/balanceNestTree_addChild.sql} (54%) rename db/routines/{vn2008/procedures/nest_delete.sql => vn/procedures/balanceNestTree_delete.sql} (52%) create mode 100644 db/routines/vn/procedures/balanceNestTree_move.sql create mode 100644 db/routines/vn/procedures/pay.sql delete mode 100644 db/routines/vn2008/procedures/nest_move.sql delete mode 100644 db/routines/vn2008/procedures/pay.sql diff --git a/db/routines/vn2008/procedures/nest_child_add.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql similarity index 54% rename from db/routines/vn2008/procedures/nest_child_add.sql rename to db/routines/vn/procedures/balanceNestTree_addChild.sql index 5b45a9d07..d16168a59 100644 --- a/db/routines/vn2008/procedures/nest_child_add.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -1,48 +1,45 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_child_add`( - vTable VARCHAR(45) - ,vChild VARCHAR(45) - ,vFatherId INT +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`( + vSelfFather INT, + vName VARCHAR(45) ) BEGIN - DECLARE vMyLeft INT; + DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); + DECLARE vLeft INT; - SET vTable = util.quoteIdentifier(vTable); - - DROP TEMPORARY TABLE IF EXISTS aux; - CREATE TEMPORARY TABLE aux - SELECT 0 as lft; + CREATE OR REPLACE TEMPORARY TABLE tAux + SELECT 0 lft; EXECUTE IMMEDIATE CONCAT( - 'UPDATE aux + 'UPDATE tAux SET lft = (SELECT lft FROM ', vTable, ' WHERE id = ?)') USING vFatherId; - SELECT lft INTO vMyLeft FROM aux; - DROP TEMPORARY TABLE aux; + SELECT lft INTO vLeft FROM tAux; EXECUTE IMMEDIATE CONCAT( 'UPDATE ', vTable, ' SET rgt = rgt + 2 WHERE rgt > ? ORDER BY rgt DESC') - USING vMyLeft; + USING vLeft; EXECUTE IMMEDIATE CONCAT( 'UPDATE ', vTable, ' SET lft = lft + 2 WHERE lft > ? ORDER BY lft DESC') - USING vMyLeft; + USING vLeft; EXECUTE IMMEDIATE CONCAT( 'INSERT INTO ', vTable, ' (name, lft, rgt) VALUES(?, ? + 1, ? + 2)') USING vChild, - vMyLeft, - vMyLeft; - + vLeft, + vLeft; + + DROP TEMPORARY TABLE tAux; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/nest_delete.sql b/db/routines/vn/procedures/balanceNestTree_delete.sql similarity index 52% rename from db/routines/vn2008/procedures/nest_delete.sql rename to db/routines/vn/procedures/balanceNestTree_delete.sql index 84f75294b..d2f37851f 100644 --- a/db/routines/vn2008/procedures/nest_delete.sql +++ b/db/routines/vn/procedures/balanceNestTree_delete.sql @@ -1,51 +1,48 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_delete`( - vTable VARCHAR(45) - ,vNodeId INT +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`( + vSelf INT ) BEGIN - DECLARE vMyRight INT; - DECLARE vMyLeft INT; - DECLARE vMyWidth INT; + DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); + DECLARE vRight INT; + DECLARE vLeft INT; + DECLARE vWidth INT; - DROP TEMPORARY TABLE IF EXISTS aux; - CREATE TEMPORARY TABLE aux + CREATE OR REPLACE TEMPORARY TABLE tAux SELECT 0 rgt, 0 lft, 0 wdt; - - SET vTable = util.quoteIdentifier(vTable); EXECUTE IMMEDIATE CONCAT( - 'UPDATE aux a + 'UPDATE tAux a JOIN ', vTable, ' t SET a.rgt = t.rgt, a.lft = t.lft, a.wdt = t.rgt - t.lft + 1 WHERE t.id = ?') - USING vNodeId; + USING vSelf; SELECT rgt, lft, wdt - INTO vMyRight, vMyLeft, vMyWidth - FROM aux; - - DROP TEMPORARY TABLE aux; + INTO vRight, vLeft, vWidth + FROM tAux; EXECUTE IMMEDIATE CONCAT( 'DELETE FROM ', vTable, ' WHERE lft BETWEEN ? AND ?') - USING vMyLeft, vMyRight; + USING vLeft, vRight; EXECUTE IMMEDIATE CONCAT( 'UPDATE ', vTable, ' SET rgt = rgt - ? WHERE rgt > ? ORDER BY rgt') - USING vMyWidth,vMyRight; + USING vWidth,vRight; EXECUTE IMMEDIATE CONCAT( 'UPDATE ', vTable, ' SET lft = lft - ? WHERE lft > ? ORDER BY lft') - USING vMyWidth, vMyRight; + USING vWidth, vRight; + + DROP TEMPORARY TABLE tAux; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/balanceNestTree_move.sql b/db/routines/vn/procedures/balanceNestTree_move.sql new file mode 100644 index 000000000..ea7c734db --- /dev/null +++ b/db/routines/vn/procedures/balanceNestTree_move.sql @@ -0,0 +1,111 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`( + vSelfNode INT, + vSelfFather INT +) +BEGIN + DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); + DECLARE vRight INT; + DECLARE vLeft INT; + DECLARE vWidth INT; + DECLARE vFatherRight INT; + DECLARE vFatherLeft INT; + DECLARE vGap INT; + + CREATE OR REPLACE TEMPORARY TABLE tAux + SELECT 0 rgt, 0 lft, 0 wdt, 0 frg, 0 flf; + + -- Averiguamos el ancho de la rama + EXECUTE IMMEDIATE CONCAT( + 'UPDATE tAux a + JOIN ', vTable, ' t + SET a.wdt = t.rgt - t.lft + 1 + WHERE t.id = ?') + USING vSelfNode; + + -- Averiguamos la posicion del nuevo padre + EXECUTE IMMEDIATE CONCAT( + 'UPDATE tAux a + JOIN ', vTable, ' t + SET a.frg = t.rgt, + a.flf = t.lft + WHERE t.id = ?') + USING vSelfFather; + + SELECT wdt, frg, flf + INTO vWidth, vFatherRight, vFatherLeft + FROM tAux; + + -- 1º Incrementamos los valores de todos los nodos a la derecha + -- del punto de inserción (vFatherRight) , para hacer sitio + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET rgt = rgt + ? + WHERE rgt >= ? + ORDER BY rgt DESC') + USING vWidth, + vFatherRight; + + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET lft = lft + ? + WHERE lft >= ? + ORDER BY lft DESC') + USING vWidth, + vFatherRight; + + -- Es preciso recalcular los valores del nodo en el + -- caso de que estuviera a la derecha del nuevo padre + EXECUTE IMMEDIATE CONCAT( + 'UPDATE tAux a + JOIN ', vTable, ' t + SET a.rgt = t.rgt, + a.lft = t.lft + WHERE t.id = ?') + USING vSelfNode; + + SELECT lft, rgt, frg - lft + INTO vLeft, vRight, vGap + FROM tAux; + + -- 2º Incrementamos el valor de todos los nodos a + -- trasladar hasta alcanzar su nueva posicion + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET lft = lft + ? + WHERE lft BETWEEN ? AND ? + ORDER BY lft DESC') + USING vGap, + vLeft, + vRight; + + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET rgt = rgt + ? + WHERE rgt BETWEEN ? AND ? + ORDER BY rgt DESC') + USING vGap, + vLeft, + vRight; + + -- 3º Restaremos a todos los nodos resultantes, a la derecha + -- de la posicion arrancada el ancho de la rama escindida + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET lft = lft - ? + WHERE lft > ? + ORDER BY lft') + USING vWidth, + vLeft; + + EXECUTE IMMEDIATE CONCAT( + 'UPDATE ', vTable, + 'SET rgt = rgt - ? + WHERE rgt > ? + ORDER BY rgt') + USING vWidth, + vRight; + + DROP TEMPORARY TABLE tAux; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/pay.sql b/db/routines/vn/procedures/pay.sql new file mode 100644 index 000000000..42b7a6a55 --- /dev/null +++ b/db/routines/vn/procedures/pay.sql @@ -0,0 +1,68 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`pay`( + vDated DATE, + vSupplierFk INT, + vAmount DOUBLE, + vCurrencyFk INT, + vDivisa DOUBLE, + vBankFk INT, + vPayMethodFk INT, + vExpenseFk DOUBLE, + vConcept VARCHAR(40), + vCompanyFk INT) +BEGIN + INSERT INTO till( + concept, + serie, + `number`, + `out`, + dated, + isAccountable, + bankFk, + workerFk, + companyFk, + isConciliate + ) + SELECT CONCAT('n/pago a ', `name`), + 'R', + vSupplierFk, + vAmount, + vDated, + 1, + vBankFk, + account.myUser_getId(), + vCompanyFk, + 1 + FROM supplier + WHERE id = vSupplierFk; + + INSERT INTO payment( + received, + dueDated, + supplierFk, + amount, + currencyFk, + divisa, + bankFk, + payMethodFk, + bankingFees, + concept, + companyFk + ) + VALUES( + vDated, + vDated, + vSupplierFk, + vAmount, + vCurrencyFk, + IF(NOT vDivisa, NULL, vDivisa), + vBankFk, + vPayMethodFk, + vExpenseFk, + vConcept, + vCompanyFk + ); + + SELECT LAST_INSERT_ID() pago_id; +END$$ +DELIMITER ; diff --git a/db/routines/vn2008/procedures/nest_move.sql b/db/routines/vn2008/procedures/nest_move.sql deleted file mode 100644 index 950d46e68..000000000 --- a/db/routines/vn2008/procedures/nest_move.sql +++ /dev/null @@ -1,108 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`nest_move`( - vTable VARCHAR(45) - ,idNODE INT - ,idFATHER INT -) -BEGIN - DECLARE myRight INT; - DECLARE myLeft INT; - DECLARE myWidth INT; - DECLARE fatherRight INT; - DECLARE fatherLeft INT; - DECLARE gap INT; - - SET vTable = util.quoteIdentifier(vTable); - - DROP TEMPORARY TABLE IF EXISTS aux; - CREATE TEMPORARY TABLE aux - SELECT 0 as rgt, 0 as lft, 0 as wdt, 0 as frg, 0 as flf; - - -- Averiguamos el ancho de la rama - EXECUTE IMMEDIATE CONCAT( - 'UPDATE aux a - JOIN ', vTable, ' t - SET a.wdt = t.rgt - t.lft + 1 - WHERE t.id = ?') - USING idNODE; - - -- Averiguamos la posicion del nuevo padre - EXECUTE IMMEDIATE CONCAT( - 'UPDATE aux a - JOIN ', vTable, ' t - SET a.frg = t.rgt, - a.flf = t.lft - WHERE t.id = ?') - USING idFATHER; - - SELECT wdt, frg, flf INTO myWidth, fatherRight, fatherLeft - FROM aux; - - -- 1º Incrementamos los valores de todos los nodos a la derecha del punto de inserción (fatherRight) , para hacer sitio - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET rgt = rgt + ? - WHERE rgt >= ? - ORDER BY rgt DESC') - USING myWidth, - fatherRight; - - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET lft = lft + ? - WHERE lft >= ? - ORDER BY lft DESC') - USING myWidth, - fatherRight; - - -- Es preciso recalcular los valores del nodo en el caso de que estuviera a la derecha del nuevo padre - EXECUTE IMMEDIATE CONCAT( - 'UPDATE aux a - JOIN ', vTable, ' t - SET a.rgt = t.rgt, - a.lft = t.lft - WHERE t.id = ?') - USING idNODE; - - SELECT lft, rgt, frg - lft INTO myLeft, myRight, gap - FROM aux; - - -- 2º Incrementamos el valor de todos los nodos a trasladar hasta alcanzar su nueva posicion - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET lft = lft + ? - WHERE lft BETWEEN ? AND ? - ORDER BY lft DESC') - USING gap, - myLeft, - myRight; - - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET rgt = rgt + ? - WHERE rgt BETWEEN ? AND ? - ORDER BY rgt DESC') - USING gap, - myLeft, - myRight; - - -- 3º Restaremos a todos los nodos resultantes, a la derecha de la posicion arrancada el ancho de la rama escindida - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET lft = lft - ? - WHERE lft > ? - ORDER BY lft') - USING myWidth, - myLeft; - - EXECUTE IMMEDIATE CONCAT( - 'UPDATE ', vTable, - 'SET rgt = rgt - ? - WHERE rgt > ? - ORDER BY rgt') - USING myWidth, - myRight; - - DROP TEMPORARY TABLE aux; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/pay.sql b/db/routines/vn2008/procedures/pay.sql deleted file mode 100644 index ec73ee696..000000000 --- a/db/routines/vn2008/procedures/pay.sql +++ /dev/null @@ -1,67 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`pay`(IN datFEC DATE - , IN idPROV INT - , IN dblIMPORTE DOUBLE - , IN idMONEDA INT - , IN dblDIVISA DOUBLE - , IN idCAJA INT - , IN idPAYMET INT - , IN dblGASTOS DOUBLE - , IN strCONCEPTO VARCHAR(40) - , IN idEMP INT) -BEGIN - - -- Registro en la tabla Cajas - INSERT INTO Cajas ( Concepto - , Serie - , Numero - , Salida - , Cajafecha - , Partida - , Id_Banco - , Id_Trabajador - ,empresa_id - ,conciliado) - - SELECT CONCAT('n/pago a ', Proveedor) - , 'R' - , idPROV - , dblIMPORTE - , datFEC - , 1 - , idCAJA - , account.myUser_getId() - , idEMP - , 1 - FROM Proveedores - WHERE Id_Proveedor = idPROV; - - -- Registro en la tabla pago - INSERT INTO pago(fecha - , dueDated - , id_proveedor - , importe - , id_moneda - , divisa - , id_banco - , pay_met_id - , g_bancarios - , concepte - , empresa_id) - - VALUES(datFEC - , datFEC - , idPROV - , dblIMPORTE - , idMONEDA - , IF(dblDIVISA = 0, NULL, dblDIVISA) - , idCAJA - , idPAYMET - , dblGASTOS - , strCONCEPTO - , idEMP); - - SELECT LAST_INSERT_ID() as pago_id; - -END$$ -DELIMITER ; From 6c67462943343b21c5cc5292c24762665523325e Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 08:26:17 +0100 Subject: [PATCH 2/9] refactor: refs #6499 Minor changes --- db/routines/vn/procedures/balanceNestTree_addChild.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql index d16168a59..a4d6dc4b0 100644 --- a/db/routines/vn/procedures/balanceNestTree_addChild.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -15,7 +15,7 @@ BEGIN SET lft = (SELECT lft FROM ', vTable, ' WHERE id = ?)') - USING vFatherId; + USING vSelfFather; SELECT lft INTO vLeft FROM tAux; From b9c5930f68a31f93125229227a44ecdb70b5e379 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 08:29:12 +0100 Subject: [PATCH 3/9] refactor: refs #6499 Minor changes --- db/routines/vn/procedures/balanceNestTree_addChild.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql index a4d6dc4b0..7433cbb42 100644 --- a/db/routines/vn/procedures/balanceNestTree_addChild.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -36,7 +36,7 @@ BEGIN EXECUTE IMMEDIATE CONCAT( 'INSERT INTO ', vTable, ' (name, lft, rgt) VALUES(?, ? + 1, ? + 2)') - USING vChild, + USING vName, vLeft, vLeft; From cba0e55846045da31098d94f15d9e2c207a8c403 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 08:39:49 +0100 Subject: [PATCH 4/9] refactor: refs #6499 Added comments --- .../vn/procedures/balanceNestTree_addChild.sql | 11 +++++++++-- .../vn/procedures/balanceNestTree_delete.sql | 5 +++++ db/routines/vn/procedures/balanceNestTree_move.sql | 12 +++++++++--- db/routines/vn/procedures/pay.sql | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql index 7433cbb42..0f4f31b06 100644 --- a/db/routines/vn/procedures/balanceNestTree_addChild.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -1,9 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`( - vSelfFather INT, + vSelf INT, vName VARCHAR(45) ) BEGIN +/** + * Agrega u nuevo nodo hijo a un nodo existente dentro de la estructura + * de árbol de vn.balanceNestTree. + * + * @param vSelf Identificador del nodo + * @param vName Nombre del nuevo nodo hijo + */ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); DECLARE vLeft INT; @@ -15,7 +22,7 @@ BEGIN SET lft = (SELECT lft FROM ', vTable, ' WHERE id = ?)') - USING vSelfFather; + USING vSelf; SELECT lft INTO vLeft FROM tAux; diff --git a/db/routines/vn/procedures/balanceNestTree_delete.sql b/db/routines/vn/procedures/balanceNestTree_delete.sql index d2f37851f..1d6a9efff 100644 --- a/db/routines/vn/procedures/balanceNestTree_delete.sql +++ b/db/routines/vn/procedures/balanceNestTree_delete.sql @@ -3,6 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_del vSelf INT ) BEGIN +/** + * Elimina un nodo dentro de la estructura de árbol de vn.balanceNestTree. + * + * @param vSelf Identificador del nodo + */ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); DECLARE vRight INT; DECLARE vLeft INT; diff --git a/db/routines/vn/procedures/balanceNestTree_move.sql b/db/routines/vn/procedures/balanceNestTree_move.sql index ea7c734db..e4f0b9de4 100644 --- a/db/routines/vn/procedures/balanceNestTree_move.sql +++ b/db/routines/vn/procedures/balanceNestTree_move.sql @@ -1,9 +1,15 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`( - vSelfNode INT, + vSelf INT, vSelfFather INT ) BEGIN +/** + * Mueve un nodo dentro de la estructura de árbol de vn.balanceNestTree. + * + * @param vSelf Identificador del nodo + * @param vSelfFather Identificador del nuevo padre del nodo + */ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); DECLARE vRight INT; DECLARE vLeft INT; @@ -21,7 +27,7 @@ BEGIN JOIN ', vTable, ' t SET a.wdt = t.rgt - t.lft + 1 WHERE t.id = ?') - USING vSelfNode; + USING vSelf; -- Averiguamos la posicion del nuevo padre EXECUTE IMMEDIATE CONCAT( @@ -62,7 +68,7 @@ BEGIN SET a.rgt = t.rgt, a.lft = t.lft WHERE t.id = ?') - USING vSelfNode; + USING vSelf; SELECT lft, rgt, frg - lft INTO vLeft, vRight, vGap diff --git a/db/routines/vn/procedures/pay.sql b/db/routines/vn/procedures/pay.sql index 42b7a6a55..5dc21e45f 100644 --- a/db/routines/vn/procedures/pay.sql +++ b/db/routines/vn/procedures/pay.sql @@ -11,6 +11,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`pay`( vConcept VARCHAR(40), vCompanyFk INT) BEGIN +/** + * Registra un pago realizado a un proveedor. + * + * @param vDated Fecha del pago + * @param vSupplierFk Id del proveedor + * @param vAmount Cantidad a pagar + * @param vCurrencyFk Id de la moneda + * @param vDivisa Tipo de cambio utilizado + * @param vBankFk Id del banco + * @param vPayMethodFk Id del método de pago + * @param vExpenseFk Id de gasto + * @param vConcept Concepto del pago + * @param vCompanyFk Id de la empresa + */ INSERT INTO till( concept, serie, From b8e6cc9f9ce3e6221aba1385046db019daf0bb47 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 09:08:47 +0100 Subject: [PATCH 5/9] refactor: refs #6499 Added comments --- db/routines/vn/procedures/balanceNestTree_addChild.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/balanceNestTree_addChild.sql b/db/routines/vn/procedures/balanceNestTree_addChild.sql index 0f4f31b06..5cd1ab470 100644 --- a/db/routines/vn/procedures/balanceNestTree_addChild.sql +++ b/db/routines/vn/procedures/balanceNestTree_addChild.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_add ) BEGIN /** - * Agrega u nuevo nodo hijo a un nodo existente dentro de la estructura + * Agrega un nuevo nodo hijo a un nodo existente dentro de la estructura * de árbol de vn.balanceNestTree. * * @param vSelf Identificador del nodo From 9f2d1a8c0f523db3b7ec33ad90dd1d883136e8dd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Feb 2024 09:13:01 +0100 Subject: [PATCH 6/9] refactor: refs #6499 Minor change --- db/routines/vn/procedures/pay.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/pay.sql b/db/routines/vn/procedures/pay.sql index 5dc21e45f..c868bfb53 100644 --- a/db/routines/vn/procedures/pay.sql +++ b/db/routines/vn/procedures/pay.sql @@ -24,6 +24,7 @@ BEGIN * @param vExpenseFk Id de gasto * @param vConcept Concepto del pago * @param vCompanyFk Id de la empresa + * @return paymentFk Id de pago insertado */ INSERT INTO till( concept, @@ -77,6 +78,6 @@ BEGIN vCompanyFk ); - SELECT LAST_INSERT_ID() pago_id; + SELECT LAST_INSERT_ID() paymentFk; END$$ DELIMITER ; From 96bab9b27d039a04b246f01dc1439642f39b8a02 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 29 Feb 2024 07:37:23 +0100 Subject: [PATCH 7/9] refactor: refs #6496 Requested changes --- db/routines/vn/procedures/balanceNestTree_move.sql | 6 +++--- db/routines/vn/procedures/pay.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/balanceNestTree_move.sql b/db/routines/vn/procedures/balanceNestTree_move.sql index e4f0b9de4..ce29de1d9 100644 --- a/db/routines/vn/procedures/balanceNestTree_move.sql +++ b/db/routines/vn/procedures/balanceNestTree_move.sql @@ -1,14 +1,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`( vSelf INT, - vSelfFather INT + vFather INT ) BEGIN /** * Mueve un nodo dentro de la estructura de árbol de vn.balanceNestTree. * * @param vSelf Identificador del nodo - * @param vSelfFather Identificador del nuevo padre del nodo + * @param vFather Identificador del nuevo padre del nodo */ DECLARE vTable VARCHAR(45) DEFAULT util.quoteIdentifier('balanceNestTree'); DECLARE vRight INT; @@ -36,7 +36,7 @@ BEGIN SET a.frg = t.rgt, a.flf = t.lft WHERE t.id = ?') - USING vSelfFather; + USING vFather; SELECT wdt, frg, flf INTO vWidth, vFatherRight, vFatherLeft diff --git a/db/routines/vn/procedures/pay.sql b/db/routines/vn/procedures/pay.sql index c868bfb53..2ef9ca2d6 100644 --- a/db/routines/vn/procedures/pay.sql +++ b/db/routines/vn/procedures/pay.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`pay`( vSupplierFk INT, vAmount DOUBLE, vCurrencyFk INT, - vDivisa DOUBLE, + vForeignValue DOUBLE, vBankFk INT, vPayMethodFk INT, vExpenseFk DOUBLE, @@ -18,7 +18,7 @@ BEGIN * @param vSupplierFk Id del proveedor * @param vAmount Cantidad a pagar * @param vCurrencyFk Id de la moneda - * @param vDivisa Tipo de cambio utilizado + * @param vForeignValue Tipo de cambio utilizado * @param vBankFk Id del banco * @param vPayMethodFk Id del método de pago * @param vExpenseFk Id de gasto @@ -70,7 +70,7 @@ BEGIN vSupplierFk, vAmount, vCurrencyFk, - IF(NOT vDivisa, NULL, vDivisa), + IF(NOT vForeignValue, NULL, vForeignValue), vBankFk, vPayMethodFk, vExpenseFk, From f4aa5cea915eefc0b8872a41f16a72a660176f31 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 1 Mar 2024 07:32:45 +0100 Subject: [PATCH 8/9] refactor: refs #6499 Grants --- db/versions/10924-pinkCordyline/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10924-pinkCordyline/00-firstScript.sql diff --git a/db/versions/10924-pinkCordyline/00-firstScript.sql b/db/versions/10924-pinkCordyline/00-firstScript.sql new file mode 100644 index 000000000..ea04623cd --- /dev/null +++ b/db/versions/10924-pinkCordyline/00-firstScript.sql @@ -0,0 +1,4 @@ +GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_addChild TO adminBoss; +GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_delete TO adminBoss; +GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_move TO adminBoss; +GRANT EXECUTE ON PROCEDURE vn.pay TO financial; From fa70eeb75c78b95960c0ce265e038d77f52c4b2b Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 4 Mar 2024 13:42:11 +0100 Subject: [PATCH 9/9] refactor: refs #6499 Requested changes --- .../procedures/{pay.sql => payment_add.sql} | 5 ++-- .../10924-pinkCordyline/00-firstScript.sql | 29 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) rename db/routines/vn/procedures/{pay.sql => payment_add.sql} (93%) diff --git a/db/routines/vn/procedures/pay.sql b/db/routines/vn/procedures/payment_add.sql similarity index 93% rename from db/routines/vn/procedures/pay.sql rename to db/routines/vn/procedures/payment_add.sql index 2ef9ca2d6..061a75848 100644 --- a/db/routines/vn/procedures/pay.sql +++ b/db/routines/vn/procedures/payment_add.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`pay`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`payment_add`( vDated DATE, vSupplierFk INT, vAmount DOUBLE, @@ -12,7 +12,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`pay`( vCompanyFk INT) BEGIN /** - * Registra un pago realizado a un proveedor. + * Registra un pago realizado a un proveedor y + * su correspondiente registro en caja. * * @param vDated Fecha del pago * @param vSupplierFk Id del proveedor diff --git a/db/versions/10924-pinkCordyline/00-firstScript.sql b/db/versions/10924-pinkCordyline/00-firstScript.sql index ea04623cd..1c6c1c0f8 100644 --- a/db/versions/10924-pinkCordyline/00-firstScript.sql +++ b/db/versions/10924-pinkCordyline/00-firstScript.sql @@ -1,4 +1,31 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_addChild`() +BEGIN + SELECT 1; +END$$ +DELIMITER ; GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_addChild TO adminBoss; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_delete`() +BEGIN + SELECT 1; +END$$ +DELIMITER ; GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_delete TO adminBoss; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balanceNestTree_move`() +BEGIN + SELECT 1; +END$$ +DELIMITER ; GRANT EXECUTE ON PROCEDURE vn.balanceNestTree_move TO adminBoss; -GRANT EXECUTE ON PROCEDURE vn.pay TO financial; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`payment_add`() +BEGIN + SELECT 1; +END$$ +DELIMITER ; +GRANT EXECUTE ON PROCEDURE vn.payment_add TO financial;