salix/modules/order/back/methods/order/getTotalVolume.js

33 lines
911 B
JavaScript

module.exports = Self => {
Self.remoteMethod('getTotalVolume', {
description: 'Gets the total volume for an order',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'ticket id',
http: {source: 'path'}
}],
returns: {
type: 'number',
root: true
},
http: {
path: `/:id/getTotalVolume`,
verb: 'GET'
}
});
Self.getTotalVolume = async(orderFk, options) => {
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const query = `SELECT vn.orderTotalVolume(?) totalVolume, vn.orderTotalVolumeBoxes(?) totalBoxes`;
const [res] = await Self.rawSql(query, [orderFk, orderFk], myOptions);
return res;
};
};