feat: refs #6276 test itemShelving_return
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6be2f07c22
commit
c0398d17bf
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
const filterItemShelvings = {
|
||||
fields: ['id', 'visible', 'itemFk', 'packing', 'grouping', 'isChecked', 'shelvingFk'],
|
||||
fields: ['id', 'visible', 'itemFk', 'shelvingFk'],
|
||||
where: {shelvingFk},
|
||||
include: [
|
||||
{
|
||||
|
@ -34,47 +34,28 @@ module.exports = Self => {
|
|||
fields: ['longName', 'name', 'size']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'shelving',
|
||||
|
||||
scope: {
|
||||
include: {
|
||||
fields: ['id', 'name', 'code'],
|
||||
relation: 'parking',
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
let itemShelvings = await models.ItemShelving.find(filterItemShelvings, myOptions);
|
||||
|
||||
const [alternatives] = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)', [shelvingFk]);
|
||||
const [alternatives] = await models.ItemShelving.rawSql(
|
||||
'CALL vn.itemShelving_getAlternatives(?)', [shelvingFk]
|
||||
);
|
||||
|
||||
if (itemShelvings) {
|
||||
itemShelvings = itemShelvings.map(itemShelving => {
|
||||
return itemShelvings.map(itemShelving => {
|
||||
const item = itemShelving.item();
|
||||
const shelving = itemShelving.shelving();
|
||||
const parking = shelving ? shelving.parking() : null;
|
||||
|
||||
const carros = alternatives.filter(el => el.itemFk == itemShelving.itemFk);
|
||||
const carros = alternatives.filter(alternative => alternative.itemFk == itemShelving.itemFk);
|
||||
|
||||
return {
|
||||
id: itemShelving.id,
|
||||
itemFk: itemShelving.itemFk,
|
||||
longName: item ? item.longName || `${item.name} ${item.size}` : '',
|
||||
quantity: itemShelving.visible,
|
||||
stickers: Math.ceil(itemShelving.visible / itemShelving.packing),
|
||||
packing: itemShelving.packing,
|
||||
grouping: itemShelving.grouping,
|
||||
code: parking ? parking.code : '',
|
||||
priority: shelving ? shelving.priority : 0,
|
||||
isChecked: itemShelving.isChecked,
|
||||
carros
|
||||
};
|
||||
});
|
||||
}
|
||||
return itemShelvings;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('itemShelving return()', () => {
|
||||
fdescribe('itemShelving return()', () => {
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
accessToken: {userId: 9},
|
||||
|
@ -11,9 +11,22 @@ describe('itemShelving return()', () => {
|
|||
});
|
||||
|
||||
it('should return a list of items and alternative locations', async() => {
|
||||
const itemShelvings = await models.itemShelving.return('HEJ');
|
||||
const itemShelvings = await models.ItemShelving.return('PCC');
|
||||
|
||||
expect(itemShelvings).toBeDefined();
|
||||
// WIP
|
||||
expect(itemShelvings[0].itemFk).toEqual(999997);
|
||||
expect(itemShelvings[0].quantity).toEqual(10);
|
||||
expect(itemShelvings[0].carros.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return a list of items without alternatives', async() => {
|
||||
const itemShelvings = await models.ItemShelving.return('HEJ');
|
||||
|
||||
expect(itemShelvings[0].carros.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should return an empty list', async() => {
|
||||
const itemShelvings = await models.ItemShelving.return('ZZP');
|
||||
|
||||
expect(itemShelvings.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue