salix/services/loopback/common/methods/ticket/getTotalVolume.js

25 lines
699 B
JavaScript
Raw Normal View History

module.exports = Self => {
Self.remoteMethod('getTotalVolume', {
description: 'Returns the total volume of a ticket',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'ticket id',
http: {source: 'path'}
}],
returns: {
root: true
},
http: {
path: `/:id/getTotalVolume`,
verb: 'GET'
}
});
Self.getTotalVolume = async ticketFk => {
return (await Self.rawSql(`SELECT vn.ticketTotalVolume(?) totalVolume, vn.ticketTotalVolumeBoxes(?) totalBoxes`, [ticketFk, ticketFk]))[0];
};
};