#6276 createNewWarehouse methods migrated from silex to salix #1850
|
@ -0,0 +1,77 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('return', {
|
||||
jorgep marked this conversation as resolved
Outdated
|
||||
description: 'Returns a list of items and possible alternative locations',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'shelvingFk',
|
||||
type: 'string',
|
||||
required: true,
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/return`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.return = async(shelvingFk, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const filterItemShelvings = {
|
||||
fields: ['id', 'visible', 'itemFk', 'packing', 'grouping', 'isChecked', 'shelvingFk'],
|
||||
where: {shelvingFk},
|
||||
include: [
|
||||
{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
fields: ['longName', 'name', 'size']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'shelving',
|
||||
|
||||
scope: {
|
||||
include: {
|
||||
fields: ['id', 'name', 'code'],
|
||||
jorgep marked this conversation as resolved
Outdated
jgallego
commented
si eso se usa en el if, porque no lo mueves dentro, así en los casos que no haya itemShelvings no es necesario ejecutarlo? si eso se usa en el if, porque no lo mueves dentro, así en los casos que no haya itemShelvings no es necesario ejecutarlo?
|
||||
relation: 'parking',
|
||||
jorgep marked this conversation as resolved
Outdated
alexm
commented
En salix para poder loggear los cambios en CALLs hace falta que el myOptions tenga el userId En salix para poder loggear los cambios en CALLs hace falta que el myOptions tenga el userId
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
let itemShelvings = await models.ItemShelving.find(filterItemShelvings, myOptions);
|
||||
|
||||
let alternatives = await models.ItemShelving.rawSql('CALL vn.itemShelving_getAlternatives(?)', [shelvingFk]);
|
||||
console.log(alternatives);
|
||||
|
||||
if (itemShelvings) {
|
||||
itemShelvings = itemShelvings.map(itemShelving => {
|
||||
const item = itemShelving.item();
|
||||
const shelving = itemShelving.shelving();
|
||||
const parking = shelving ? shelving.parking() : null;
|
||||
|
||||
return {
|
||||
item: itemShelving.itemFk,
|
||||
description: item ? item.longName || `${item.name} ${item.size}` : '',
|
||||
visible: itemShelving.visible,
|
||||
stickers: Math.ceil(itemShelving.visible / itemShelving.packing),
|
||||
packing: itemShelving.packing,
|
||||
grouping: itemShelving.grouping,
|
||||
code: parking ? parking.code : '',
|
||||
id: itemShelving.id,
|
||||
priority: shelving ? shelving.priority : 0,
|
||||
isChecked: itemShelving.isChecked
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
|
@ -2,4 +2,5 @@ module.exports = Self => {
|
|||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||
require('../methods/item-shelving/getInventory')(Self);
|
||||
require('../methods/item-shelving/makeMulti')(Self);
|
||||
require('../methods/item-shelving/return')(Self);
|
||||
};
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
"shelving": {
|
||||
"type": "belongsTo",
|
||||
"model": "Shelving",
|
||||
"foreignKey": "shelvingFk"
|
||||
}
|
||||
"foreignKey": "shelvingFk",
|
||||
"primaryKey": "code"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
getAlternative