hotfix: ledger_next transacciones refs #7523
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
a73c98eebe
commit
83b8fc38bd
|
@ -44,7 +44,7 @@ BEGIN
|
||||||
JOIN dua d ON d.id = de.duaFk
|
JOIN dua d ON d.id = de.duaFk
|
||||||
WHERE d.id = vDuaFk
|
WHERE d.id = vDuaFk
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
CALL ledger_next(vFiscalYear, FALSE, vBookEntry);
|
CALL ledger_nextTx(vFiscalYear, FALSE, vBookEntry);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
OPEN vInvoicesIn;
|
OPEN vInvoicesIn;
|
||||||
|
|
|
@ -12,7 +12,7 @@ BEGIN
|
||||||
WHERE id = vDuaFk;
|
WHERE id = vDuaFk;
|
||||||
|
|
||||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||||
CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber);
|
CALL ledger_nextTx(YEAR(vBookDated), FALSE, vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Apunte de la aduana
|
-- Apunte de la aduana
|
||||||
|
|
|
@ -70,7 +70,7 @@ BEGIN
|
||||||
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||||
|
|
||||||
IF vBookNumber IS NULL THEN
|
IF vBookNumber IS NULL THEN
|
||||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
CALL ledger_nextTx(vFiscalYear, FALSE, vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Apunte del proveedor
|
-- Apunte del proveedor
|
||||||
|
|
|
@ -61,7 +61,7 @@ BEGIN
|
||||||
WHERE io.id = vInvoice;
|
WHERE io.id = vInvoice;
|
||||||
|
|
||||||
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
CALL ledger_nextTx(vFiscalYear, FALSE, vBookNumber);
|
||||||
-- Linea del cliente
|
-- Linea del cliente
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
||||||
DECLARE vIsOriginalAClient BOOL;
|
DECLARE vIsOriginalAClient BOOL;
|
||||||
DECLARE vPayMethodCompensation INT;
|
DECLARE vPayMethodCompensation INT;
|
||||||
|
|
||||||
CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry);
|
CALL ledger_nextTx(YEAR(vDated), FALSE, vNewBookEntry);
|
||||||
|
|
||||||
SELECT COUNT(id) INTO vIsOriginalAClient
|
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||||
FROM client
|
FROM client
|
||||||
|
|
|
@ -1,38 +1,21 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||||
IN vFiscalYear INT,
|
IN vFiscalYear INT,
|
||||||
IN vIsManageTransaction BOOLEAN,
|
|
||||||
OUT vLastBookEntry 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
|
||||||
|
* No inicia transacción, para transaccionar usar vn.ledger_nextTx
|
||||||
|
*
|
||||||
|
* @param vFiscalYear Id del año contable
|
||||||
|
* @return vLastBookEntry Id del asiento
|
||||||
|
*/
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vHasStartTransaction BOOLEAN;
|
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
IF vHasStartTransaction THEN
|
|
||||||
ROLLBACK TO sp;
|
|
||||||
RESIGNAL;
|
|
||||||
ELSE
|
|
||||||
ROLLBACK;
|
|
||||||
CALL util.throw ('It has not been possible to generate a new ledger');
|
|
||||||
END IF;
|
|
||||||
END;
|
|
||||||
|
|
||||||
IF vFiscalYear IS NULL THEN
|
IF vFiscalYear IS NULL THEN
|
||||||
CALL util.throw('Fiscal year is required');
|
CALL util.throw('Fiscal year is required');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT vIsManageTransaction THEN
|
|
||||||
SELECT @@in_transaction INTO vHasStartTransaction;
|
|
||||||
|
|
||||||
IF NOT vHasStartTransaction THEN
|
|
||||||
START TRANSACTION;
|
|
||||||
ELSE
|
|
||||||
SAVEPOINT sp;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
SELECT bookEntry + 1 INTO vLastBookEntry
|
SELECT bookEntry + 1 INTO vLastBookEntry
|
||||||
FROM ledgerCompany
|
FROM ledgerCompany
|
||||||
WHERE fiscalYear = vFiscalYear
|
WHERE fiscalYear = vFiscalYear
|
||||||
|
@ -48,13 +31,5 @@ BEGIN
|
||||||
UPDATE ledgerCompany
|
UPDATE ledgerCompany
|
||||||
SET bookEntry = vLastBookEntry
|
SET bookEntry = vLastBookEntry
|
||||||
WHERE fiscalYear = vFiscalYear;
|
WHERE fiscalYear = vFiscalYear;
|
||||||
|
|
||||||
IF NOT vIsManageTransaction THEN
|
|
||||||
IF vHasStartTransaction THEN
|
|
||||||
RELEASE SAVEPOINT sp;
|
|
||||||
ELSE
|
|
||||||
COMMIT;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,35 @@
|
||||||
|
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
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
IF vFiscalYear IS NULL THEN
|
||||||
|
CALL util.throw('Fiscal year is required');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF @@in_transaction THEN
|
||||||
|
CALL util.throw('This procedure should not be executed within a transaction');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
CALL ledger_next(vFiscalYear, vLastBookEntry);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -39,7 +39,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
|
||||||
*/
|
*/
|
||||||
BEGIN
|
BEGIN
|
||||||
IF vBookNumber IS NULL THEN
|
IF vBookNumber IS NULL THEN
|
||||||
CALL ledger_next(YEAR(vDated), FALSE, vBookNumber);
|
CALL ledger_nextTx(YEAR(vDated), FALSE, vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO XDiario
|
INSERT INTO XDiario
|
||||||
|
|
|
@ -23,7 +23,7 @@ BEGIN
|
||||||
FROM supplier
|
FROM supplier
|
||||||
WHERE id = NEW.supplierFk;
|
WHERE id = NEW.supplierFk;
|
||||||
|
|
||||||
CALL ledger_next(YEAR(NEW.received), TRUE, vNewBookEntry);
|
CALL ledger_next(YEAR(NEW.received), vNewBookEntry);
|
||||||
|
|
||||||
INSERT INTO XDiario (
|
INSERT INTO XDiario (
|
||||||
ASIEN,
|
ASIEN,
|
||||||
|
|
Loading…
Reference in New Issue