Merge pull request '2384 - Searchbar filters fixed' (#349) from 2384-client_consumption into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #349
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Joan Sanchez 2020-08-12 10:06:55 +00:00
commit de1a70aee7
2 changed files with 32 additions and 8 deletions

View File

@ -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});

View File

@ -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);
});
});