8524-devToTest #3415
|
@ -12,18 +12,19 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vNewEntryFk INT;
|
DECLARE vNewEntryFk INT;
|
||||||
|
|
||||||
|
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vIsRequiredTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vIsRequiredTx);
|
||||||
|
|
||||||
CALL entry_cloneHeader(vSelf, vNewEntryFk, NULL);
|
CALL entry_cloneHeader(vSelf, vNewEntryFk, NULL);
|
||||||
CALL entry_copyBuys(vSelf, vNewEntryFk);
|
CALL entry_copyBuys(vSelf, vNewEntryFk);
|
||||||
|
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
SET vOutputEntryFk = vNewEntryFk;
|
SET vOutputEntryFk = vNewEntryFk;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -19,16 +19,18 @@ BEGIN
|
||||||
DECLARE vAgencyModeFk INT;
|
DECLARE vAgencyModeFk INT;
|
||||||
DECLARE vTomorrow DATETIME DEFAULT util.tomorrow();
|
DECLARE vTomorrow DATETIME DEFAULT util.tomorrow();
|
||||||
|
|
||||||
|
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vIsRequiredTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
-- Clonar la entrada
|
-- Clonar la entrada
|
||||||
CALL entry_clone(vOriginalEntry, vNewEntryFk);
|
CALL entry_clone(vOriginalEntry, vNewEntryFk);
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vIsRequiredTx);
|
||||||
|
|
||||||
|
|
||||||
-- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel.
|
-- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel.
|
||||||
SELECT t.warehouseInFk, t.warehouseOutFk, t.`ref`, t.isReceived, t.agencyModeFk
|
SELECT t.warehouseInFk, t.warehouseOutFk, t.`ref`, t.isReceived, t.agencyModeFk
|
||||||
|
@ -146,7 +148,7 @@ BEGIN
|
||||||
-- Limpia la nueva entrada
|
-- Limpia la nueva entrada
|
||||||
DELETE FROM buy WHERE entryFk = vNewEntryFk AND quantity = 0;
|
DELETE FROM buy WHERE entryFk = vNewEntryFk AND quantity = 0;
|
||||||
|
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
|
|
||||||
CALL cache.visible_refresh(@c,TRUE,vWarehouseFk);
|
CALL cache.visible_refresh(@c,TRUE,vWarehouseFk);
|
||||||
CALL cache.available_refresh(@c, TRUE, vWarehouseFk, util.VN_CURDATE());
|
CALL cache.available_refresh(@c, TRUE, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
|
@ -17,13 +17,12 @@ describe('Transfer merchandise from one entry to the next day()', () => {
|
||||||
const currentItemShelving = await models.ItemShelving.findOne({where: {id}}, options);
|
const currentItemShelving = await models.ItemShelving.findOne({where: {id}}, options);
|
||||||
await currentItemShelving.updateAttributes({itemFk: item, buyFk: buy}, options);
|
await currentItemShelving.updateAttributes({itemFk: item, buyFk: buy}, options);
|
||||||
|
|
||||||
const result = await models.Entry.transfer(ctx, originalEntry, options);
|
const [{newEntryFk}] = await models.Entry.transfer(ctx, originalEntry, options);
|
||||||
|
|
||||||
const originalEntrybuys = await models.Buy.find({where: {entryFk: originalEntry}}, options);
|
const originalEntrybuys = await models.Buy.find({where: {entryFk: originalEntry}}, options);
|
||||||
|
|
||||||
const newEntrybuys = await models.Buy.find({where: {entryFk: result[0].newEntryFk}}, options);
|
const newEntrybuys = await models.Buy.find({where: {entryFk: newEntryFk}}, options);
|
||||||
|
|
||||||
const newTravel = await models.Entry.find({where: {id: result[0].newEntryFk}}, options);
|
await models.Entry.find({where: {id: newEntryFk}}, options);
|
||||||
|
|
||||||
const itemShelvingsWithBuys = await models.Buy.find({
|
const itemShelvingsWithBuys = await models.Buy.find({
|
||||||
include: {
|
include: {
|
||||||
|
@ -39,9 +38,6 @@ describe('Transfer merchandise from one entry to the next day()', () => {
|
||||||
|
|
||||||
expect(newEntrybuys.length).toEqual(originalEntrybuys.length - hasItemShelving.length);
|
expect(newEntrybuys.length).toEqual(originalEntrybuys.length - hasItemShelving.length);
|
||||||
|
|
||||||
await models.Travel.destroyById(newTravel, options);
|
|
||||||
await models.Entry.destroyById(result[0].newEntryFk, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Self.rawSql('CALL vn.entry_transfer(?, @vNewEntry)', [id], myOptions);
|
await Self.rawSql('CALL vn.entry_transfer(?, @vNewEntry)', [id], myOptions);
|
||||||
const newEntryFk = await Self.rawSql('SELECT @vNewEntry newEntryFk', [], myOptions);
|
const newEntryFk = await Self.rawSql('SELECT @vNewEntry newEntryFk', null, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
return newEntryFk;
|
return newEntryFk;
|
||||||
|
|
Loading…
Reference in New Issue