Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2388_export-structure

This commit is contained in:
Bernat Exposito Domenech 2020-08-12 14:22:55 +02:00
commit a523030c54
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);
});
});