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', type: 'String',
description: `If it's and integer searchs by id, otherwise it searchs by name` description: `If it's and integer searchs by id, otherwise it searchs by name`
}, { }, {
arg: 'itemFk', arg: 'itemId',
type: 'Integer', type: 'Number',
description: 'Item id' description: 'Item id'
}, { }, {
arg: 'categoryFk', arg: 'categoryId',
type: 'Integer', type: 'Number',
description: 'Category id' description: 'Category id'
}, { }, {
arg: 'typeFk', arg: 'typeId',
type: 'Integer', type: 'Number',
description: 'Item type id', description: 'Item type id',
}, { }, {
arg: 'buyerFk', arg: 'buyerId',
type: 'Integer', type: 'Number',
description: 'Buyer id' description: 'Buyer id'
}, { }, {
arg: 'from', arg: 'from',
@ -75,6 +75,10 @@ module.exports = Self => {
return {'it.id': value}; return {'it.id': value};
case 'buyerId': case 'buyerId':
return {'it.workerFk': value}; return {'it.workerFk': value};
case 'from':
return {'t.shipped': {gte: value}};
case 'to':
return {'t.shipped': {lte: value}};
} }
}); });
filter = mergeFilters(filter, {where}); filter = mergeFilters(filter, {where});

View File

@ -37,4 +37,24 @@ describe('client consumption() filter', () => {
expect(secondRow.quantity).toEqual(15); expect(secondRow.quantity).toEqual(15);
expect(thirdRow.quantity).toEqual(20); 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);
});
}); });