From b33594e0daccf5af6c5c59ce4ece657db45bc2aa Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 18 Jan 2024 14:35:51 +0100 Subject: [PATCH] fix: refs #6276 item_card & wip test --- modules/item/back/methods/item/card.js | 7 +++---- modules/item/back/methods/item/specs/card.spec.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 modules/item/back/methods/item/specs/card.spec.js diff --git a/modules/item/back/methods/item/card.js b/modules/item/back/methods/item/card.js index 41d134f3b..dec6047a7 100644 --- a/modules/item/back/methods/item/card.js +++ b/modules/item/back/methods/item/card.js @@ -30,14 +30,13 @@ module.exports = Self => { const [result] = await Self.rawSql('CALL vn.item_getInfo(?, ?)', [itemFk, warehouseFk]); const barcodeItems = await Self.rawSql('SELECT vn.barcodeToItem(?) as realIdItem', [itemFk]); - const realIdItems = barcodeItems.map(barcodeItem => barcodeItem.realIdItem); + const [realIdItem] = barcodeItems.map(barcodeItem => barcodeItem.realIdItem); const barcodes = await models.ItemBarcode.find({ fields: ['code'], where: { - realIdItem: { - inq: realIdItems - } + itemFk: realIdItem + } }); diff --git a/modules/item/back/methods/item/specs/card.spec.js b/modules/item/back/methods/item/specs/card.spec.js new file mode 100644 index 000000000..433384261 --- /dev/null +++ b/modules/item/back/methods/item/specs/card.spec.js @@ -0,0 +1,12 @@ +const {models} = require('vn-loopback/server/server'); + +fdescribe('item card()', () => { + const itemFk = 1; + const warehouseFk = 1; + it('WIP: should get something', async() => { + const card = await models.Item.card(itemFk, warehouseFk); + + expect(card).toBeDefined(); + expect(card.barcodes); + }); +});