From 1fbb84ae9fc424ca03fc491f9db97600a1b8d147 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 17 Jan 2024 12:58:57 +0100 Subject: [PATCH] fix: refs #6276 itemShelving_return --- db/dump/fixtures.sql | 3 --- .../item/back/methods/item-shelving/return.js | 4 ++-- .../item-shelving/specs/return.spec.js | 19 +++++++++++++++++++ .../expedition-pallet/specs/getPallet.spec.js | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 modules/item/back/methods/item-shelving/specs/return.spec.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2b04327cf..bab0149e1 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -3047,9 +3047,6 @@ INSERT INTO `vn`.`clientSms` (`id`, `clientFk`, `smsFk`, `ticketFk`) -- NEW WAREHOUSE -/* UPDATE vn.packaging - SET id='--' - WHERE id='pallet 100'; */ INSERT INTO vn.packaging VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0); diff --git a/modules/item/back/methods/item-shelving/return.js b/modules/item/back/methods/item-shelving/return.js index 27bc39a50..61d695c48 100644 --- a/modules/item/back/methods/item-shelving/return.js +++ b/modules/item/back/methods/item-shelving/return.js @@ -50,7 +50,7 @@ module.exports = Self => { let itemShelvings = await models.ItemShelving.find(filterItemShelvings, myOptions); - const alternatives = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)', [shelvingFk]); + const [alternatives] = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)', [shelvingFk]); if (itemShelvings) { itemShelvings = itemShelvings.map(itemShelving => { @@ -58,7 +58,7 @@ module.exports = Self => { const shelving = itemShelving.shelving(); const parking = shelving ? shelving.parking() : null; - const carros = alternatives.filter(el => el.item == itemShelving.itemFk); + const carros = alternatives.filter(el => el.itemFk == itemShelving.itemFk); return { id: itemShelving.id, diff --git a/modules/item/back/methods/item-shelving/specs/return.spec.js b/modules/item/back/methods/item-shelving/specs/return.spec.js new file mode 100644 index 000000000..35676a6ac --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/return.spec.js @@ -0,0 +1,19 @@ +const {models} = require('vn-loopback/server/server'); + +describe('itemShelving return()', () => { + beforeAll(async() => { + ctx = { + accessToken: {userId: 9}, + req: { + headers: {origin: 'http://localhost'}, + } + }; + }); + + it('should return a list of items and alternative locations', async() => { + const itemShelvings = await models.itemShelving.return('HEJ'); + + expect(itemShelvings).toBeDefined(); + // WIP + }); +}); diff --git a/modules/ticket/back/methods/expedition-pallet/specs/getPallet.spec.js b/modules/ticket/back/methods/expedition-pallet/specs/getPallet.spec.js index 8a451c917..84bb9f93a 100644 --- a/modules/ticket/back/methods/expedition-pallet/specs/getPallet.spec.js +++ b/modules/ticket/back/methods/expedition-pallet/specs/getPallet.spec.js @@ -21,7 +21,7 @@ describe('expeditonPallet getPallet()', () => { it('should throw an error when the pallet does not exist', async() => { try { - await models.ExpeditionPallet.getPallet(ctx, 1); + await models.ExpeditionPallet.getPallet(ctx, 600); } catch (e) { const error = e;