34 lines
903 B
JavaScript
34 lines
903 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, options) => {
|
|
const myOptions = {};
|
|
|
|
if (typeof options == 'object')
|
|
Object.assign(myOptions, options);
|
|
|
|
const volumeData = await Self.rawSql(`
|
|
SELECT vn.ticketTotalVolume(?) totalVolume, vn.ticketTotalVolumeBoxes(?) totalBoxes
|
|
`, [ticketFk, ticketFk], myOptions);
|
|
|
|
return volumeData[0];
|
|
};
|
|
};
|