feat: refs #6822 return newEntry
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Robert Ferrús 2024-07-17 10:28:22 +02:00
parent 1332aef213
commit 109770b0a3
2 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_transfer`(vOriginalEntry INT, OUT vNewEntry INT)
BEGIN
/**
* Adelanta a mañana la mercancia de una entrada a partir de lo que hay ubicado en el almacén
@ -11,6 +11,16 @@ BEGIN
DECLARE vTravelFk INT;
DECLARE vWarehouseFk INT;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
START TRANSACTION;
-- Clonar la entrada
CALL entry_clone(vOriginalEntry,vNewEntryFk);
@ -100,6 +110,8 @@ BEGIN
WHERE b.entryFk = vNewEntryFk
AND b.quantity = 0;
SET vNewEntry = vNewEntryFk;
COMMIT;
CALL cache.visible_refresh(@c,TRUE,7);
CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE());

View File

@ -12,6 +12,10 @@ module.exports = Self => {
http: {
path: '/:id/transfer',
verb: 'POST'
},
returns: {
arg: 'newEntryFk',
type: 'number'
}
});
@ -28,8 +32,11 @@ module.exports = Self => {
}
try {
await Self.rawSql('CALL vn.entryTransfer(?)', [id], myOptions);
await Self.rawSql('CALL vn.entry_transfer(?, @vNewEntry)', [id], myOptions);
const newEntryFk = await Self.rawSql('SELECT @vNewEntry AS newEntryFk', [], myOptions);
if (tx) await tx.commit();
return newEntryFk;
} catch (e) {
if (tx) await tx.rollback();
throw e;