25 lines
699 B
JavaScript
25 lines
699 B
JavaScript
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];
|
|
};
|
|
};
|