diff --git a/modules/client/back/methods/client/consumption.js b/modules/client/back/methods/client/consumption.js index 20e1582973..537efb9d16 100644 --- a/modules/client/back/methods/client/consumption.js +++ b/modules/client/back/methods/client/consumption.js @@ -18,19 +18,19 @@ module.exports = Self => { description: `If it's and integer searchs by id, otherwise it searchs by name` }, { arg: 'itemId', - type: 'Integer', + type: 'Number', description: 'Item id' }, { arg: 'categoryId', - type: 'Integer', + type: 'Number', description: 'Category id' }, { arg: 'typeId', - type: 'Integer', + type: 'Number', description: 'Item type id', }, { arg: 'buyerId', - type: 'Integer', + type: 'Number', description: 'Buyer id' }, { arg: 'from', @@ -121,6 +121,9 @@ module.exports = Self => { stmt.merge(conn.makePagination(filter)); - return conn.executeStmt(stmt); + console.log(stmt.sql); + console.log(stmt.params); + + return await conn.executeStmt(stmt); }; }; diff --git a/modules/client/back/methods/client/specs/consumption.spec.js b/modules/client/back/methods/client/specs/consumption.spec.js index e7a42a8da7..474c888e35 100644 --- a/modules/client/back/methods/client/specs/consumption.spec.js +++ b/modules/client/back/methods/client/specs/consumption.spec.js @@ -37,4 +37,24 @@ describe('client consumption() filter', () => { expect(secondRow.quantity).toEqual(15); expect(thirdRow.quantity).toEqual(20); }); + + it('should return a list of tickets from the item id 4', async() => { + const ctx = { + args: { + itemId: 4 + } + }; + const filter = { + where: { + clientFk: 101 + }, + order: 'itemTypeFk, itemName, itemSize' + }; + const result = await app.models.Client.consumption(ctx, filter); + + const expectedItemId = 4; + const firstRow = result[0]; + + expect(firstRow.itemFk).toEqual(expectedItemId); + }); });