diff --git a/modules/client/back/methods/client/consumption.js b/modules/client/back/methods/client/consumption.js index cb5b39c29..8430c4661 100644 --- a/modules/client/back/methods/client/consumption.js +++ b/modules/client/back/methods/client/consumption.js @@ -17,20 +17,20 @@ module.exports = Self => { type: 'String', description: `If it's and integer searchs by id, otherwise it searchs by name` }, { - arg: 'itemFk', - type: 'Integer', + arg: 'itemId', + type: 'Number', description: 'Item id' }, { - arg: 'categoryFk', - type: 'Integer', + arg: 'categoryId', + type: 'Number', description: 'Category id' }, { - arg: 'typeFk', - type: 'Integer', + arg: 'typeId', + type: 'Number', description: 'Item type id', }, { - arg: 'buyerFk', - type: 'Integer', + arg: 'buyerId', + type: 'Number', description: 'Buyer id' }, { arg: 'from', @@ -75,6 +75,10 @@ module.exports = Self => { return {'it.id': value}; case 'buyerId': return {'it.workerFk': value}; + case 'from': + return {'t.shipped': {gte: value}}; + case 'to': + return {'t.shipped': {lte: value}}; } }); filter = mergeFilters(filter, {where}); diff --git a/modules/client/back/methods/client/specs/consumption.spec.js b/modules/client/back/methods/client/specs/consumption.spec.js index e7a42a8da..30a0572b3 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 = {req: {accessToken: {userId: 9}}, + 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); + }); });