Hotfix: ledger_next transacciones refs #7523
gitea/salix/pipeline/pr-master There was a failure building this commit Details

This commit is contained in:
Carlos Andrés 2024-06-04 16:43:09 +02:00
parent a9eb5f7d1e
commit e4969f7061
5 changed files with 17 additions and 17 deletions

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Confirma los cambios asociados a una transacción. * Confirma los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF NOT isTx THEN IF vIsTx THEN
COMMIT; COMMIT;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Deshace los cambios asociados a una transacción. * Deshace los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param isTx es true si existe transacción asociada
*/ */
IF NOT isTx THEN IF vIsTx THEN
ROLLBACK; ROLLBACK;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Inicia una transacción. * Inicia una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF NOT isTx THEN IF vIsTx THEN
START TRANSACTION; START TRANSACTION;
END IF; END IF;
END$$ END$$

View File

@ -12,10 +12,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_nextTx`(
* @return vLastBookEntry Id del asiento * @return vLastBookEntry Id del asiento
*/ */
BEGIN BEGIN
DECLARE vhasTx BOOL DEFAULT @@in_transaction; DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
CALL util.tx_rollback(vhasTx); CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL; RESIGNAL;
END; END;
@ -23,8 +23,8 @@ BEGIN
CALL util.throw('Fiscal year is required'); CALL util.throw('Fiscal year is required');
END IF; END IF;
CALL util.tx_start(vhasTx); CALL util.tx_start(vIsRequiredTx);
CALL ledger_next(vFiscalYear, vLastBookEntry); CALL ledger_next(vFiscalYear, vLastBookEntry);
CALL util.tx_commit(vhasTx); CALL util.tx_commit(vIsRequiredTx);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -24,8 +24,8 @@ BEGIN
DECLARE vEvaNotes VARCHAR(255); DECLARE vEvaNotes VARCHAR(255);
DECLARE vDone BOOL; DECLARE vDone BOOL;
DECLARE vAuxEntryFk INT; DECLARE vAuxEntryFk INT;
DECLARE vTx BOOLEAN DEFAULT @@in_transaction; DECLARE vDoTx BOOLEAN DEFAULT NOT @@in_transaction;
DECLARE vRsEntry CURSOR FOR DECLARE vIsRequiredTx CURSOR FOR
SELECT e.id SELECT e.id
FROM entry e FROM entry e
JOIN travel t ON t.id = e.travelFk JOIN travel t ON t.id = e.travelFk
@ -35,11 +35,11 @@ BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
CALL util.tx_rollback(vTx); CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL; RESIGNAL;
END; END;
CALL util.tx_start(vTx); CALL util.tx_start(vIsRequiredTx);
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom) INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
@ -76,6 +76,6 @@ BEGIN
SET @isModeInventory = FALSE; SET @isModeInventory = FALSE;
CLOSE vRsEntry; CLOSE vRsEntry;
CALL util.tx_commit(vTx); CALL util.tx_commit(vIsRequiredTx);
END$$ END$$
DELIMITER ; DELIMITER ;