2024-06-03 18:16:27 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_nextTx`(
|
|
|
|
IN vFiscalYear INT,
|
|
|
|
OUT vLastBookEntry INT
|
|
|
|
)
|
|
|
|
/**
|
|
|
|
* Devuelve un número de asiento válido, según el contador de asientos
|
|
|
|
* tabla vn.ledgerConfig, si no existe lo inicializa a 1
|
|
|
|
* Lo hace transaccionando el proceso
|
|
|
|
*
|
|
|
|
* @param vFiscalYear Id del año contable
|
|
|
|
* @return vLastBookEntry Id del asiento
|
|
|
|
*/
|
|
|
|
BEGIN
|
2024-06-04 13:39:02 +00:00
|
|
|
DECLARE vhasTx BOOL DEFAULT @@in_transaction;
|
2024-06-03 18:16:27 +00:00
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
2024-06-04 13:39:02 +00:00
|
|
|
CALL util.tx_rollback(vhasTx);
|
2024-06-03 18:16:27 +00:00
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
|
|
|
IF vFiscalYear IS NULL THEN
|
|
|
|
CALL util.throw('Fiscal year is required');
|
|
|
|
END IF;
|
|
|
|
|
2024-06-04 13:39:02 +00:00
|
|
|
CALL util.tx_start(vhasTx);
|
2024-06-03 18:16:27 +00:00
|
|
|
CALL ledger_next(vFiscalYear, vLastBookEntry);
|
2024-06-04 13:39:02 +00:00
|
|
|
CALL util.tx_commit(vhasTx);
|
2024-06-03 18:16:27 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|