salix/modules/item/back/methods/item/getVisibleAvailable.js

38 lines
971 B
JavaScript

module.exports = Self => {
Self.remoteMethod('getVisibleAvailable', {
description: 'Returns visible and available for params',
accessType: '',
accepts: [
{
arg: 'id',
type: 'Number',
required: true,
},
{
arg: 'warehouseFk',
type: 'Number',
required: true,
}],
returns: {
type: ['object'],
root: true
},
http: {
path: `/:id/getVisibleAvailable`,
verb: 'GET'
}
});
Self.getVisibleAvailable = async(id, warehouseFk) => {
let query = `
CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`;
let options = [id, warehouseFk, false];
[res] = await Self.rawSql(query, options);
return {
available: res[0].available,
visible: res[0].visible};
};
};