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

38 lines
1022 B
JavaScript

module.exports = Self => {
Self.remoteMethod('getBalance', {
description: 'Returns the ',
accessType: 'READ',
accepts: [{
arg: 'filter',
type: 'Object',
required: true,
description: 'Filter defining where and paginated data',
http: {source: 'query'}
}],
returns: {
type: ['Object'],
root: true
},
http: {
path: `/getBalance`,
verb: 'GET'
}
});
Self.getBalance = async(filter, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const where = filter.where;
const query = 'CALL vn.item_getBalance(?, ?)';
const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk], myOptions);
for (const entry of diary)
if (entry.clientType === 'loses') entry.highlighted = true;
return diary;
};
};