#2687 - Fix Travel_cloneWithEntries #2021
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Confirma los cambios asociados a una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
COMMIT;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Deshace los cambios asociados a una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
ROLLBACK;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
jsegarra marked this conversation as resolved
|
|||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Inicia una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
START TRANSACTION;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -11,11 +11,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_cloneWithEnt
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Clona un travel junto con sus entradas y compras
|
* Clona un travel junto con sus entradas y compras
|
||||||
*
|
|
||||||
* @param vTravelFk travel plantilla a clonar
|
* @param vTravelFk travel plantilla a clonar
|
||||||
* @param vDateStart fecha del shipment del nuevo travel
|
* @param vDateStart fecha del shipment del nuevo travel
|
||||||
* @param vDateEnd fecha del landing del nuevo travel
|
* @param vDateEnd fecha del landing del nuevo travel
|
||||||
* @param vWarehouseOutFk fecha del salida del nuevo travel
|
* @param vWarehouseOutFk warehouse del salida del nuevo travel
|
||||||
* @param vWarehouseInFk warehouse de landing del nuevo travel
|
* @param vWarehouseInFk warehouse de landing del nuevo travel
|
||||||
* @param vRef referencia del nuevo travel
|
* @param vRef referencia del nuevo travel
|
||||||
* @param vAgencyModeFk del nuevo travel
|
* @param vAgencyModeFk del nuevo travel
|
||||||
|
@ -25,6 +24,7 @@ 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 vRsEntry CURSOR FOR
|
DECLARE vRsEntry CURSOR FOR
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM entry e
|
FROM entry e
|
||||||
|
@ -35,11 +35,11 @@ BEGIN
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vTx);
|
||||||
|
|
||||||
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
|
||||||
|
@ -62,7 +62,7 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
|
CALL entry_cloneHeader(vAuxEntryFk, vNewEntryFk, vNewTravelFk);
|
||||||
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
|
CALL entry_copyBuys(vAuxEntryFk, vNewEntryFk);
|
||||||
|
|
||||||
SELECT evaNotes INTO vEvaNotes
|
SELECT evaNotes INTO vEvaNotes
|
||||||
FROM entry
|
FROM entry
|
||||||
|
@ -76,6 +76,6 @@ BEGIN
|
||||||
SET @isModeInventory = FALSE;
|
SET @isModeInventory = FALSE;
|
||||||
CLOSE vRsEntry;
|
CLOSE vRsEntry;
|
||||||
|
|
||||||
COMMIT;
|
CALL util.tx_commit(vTx);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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 vTx BOOLEAN DEFAULT @@in_transaction;
|
||||||
DECLARE vRsEntry CURSOR FOR
|
DECLARE vRsEntry CURSOR FOR
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM entry e
|
FROM entry e
|
||||||
|
@ -42,7 +42,7 @@ BEGIN
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CALL util.tx_start(vTx);
|
CALL util.tx_start(vTx);
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -27,7 +27,10 @@ describe('Travel cloneWithEntries()', () => {
|
||||||
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
|
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
|
||||||
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
|
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
|
||||||
expect(travelEntries.length).toBeGreaterThan(0);
|
expect(travelEntries.length).toBeGreaterThan(0);
|
||||||
|
await models.Entry.destroyAll({
|
||||||
|
travelFk: newTravelId
|
||||||
|
}, options);
|
||||||
|
await models.Travel.destroyById(newTravelId, options);
|
||||||
alexm marked this conversation as resolved
jsegarra
commented
Comentario de Alex: Aunque fasa rollback cal borrar les entrades i el travel??? Comentario de Alex: Aunque fasa rollback cal borrar les entrades i el travel???
jsegarra
commented
Si, no hace rollback de las líneas clonadas Si, no hace rollback de las líneas clonadas
|
|||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
const travelRemoved = await models.Travel.findById(newTravelId, options);
|
const travelRemoved = await models.Travel.findById(newTravelId, options);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Quitar esos 2 saltos de linea
d9756a0f3f