Tarea #406 order.volumen

This commit is contained in:
gerard 2018-07-24 12:57:07 +02:00
parent a7ec730216
commit 81dc09999f
4 changed files with 55 additions and 2 deletions

View File

@ -22,7 +22,7 @@ module.exports = Self => {
Self.getTotal = async orderFk => {
let query = `SELECT hedera.orderGetTotal(?) total;`;
let [total] = await Self.rawSql(query, [orderFk]);
console.log(total);
return total;
};
};

View File

@ -0,0 +1,27 @@
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 => {
let query = `SELECT vn.orderTotalVolume(?) totalVolume, vn.orderTotalVolumeBoxes(?) totalBoxes`;
let [res] = await Self.rawSql(query, [orderFk, orderFk]);
return res;
};
};

View File

@ -0,0 +1,25 @@
module.exports = Self => {
Self.remoteMethod('getVolume', {
description: 'Returns the volumes of a order',
accessType: 'READ',
accepts: [{
arg: 'id',
type: 'number',
required: true,
description: 'order id',
http: {source: 'path'}
}],
returns: {
arg: 'volumes'
},
http: {
path: `/:id/getVolumes`,
verb: 'GET'
}
});
Self.getVolume = async orderFk => {
let [volume] = await Self.rawSql(`CALL vn.orderListVolume(?)`, [orderFk]);
return volume;
};
};

View File

@ -1,6 +1,7 @@
module.exports = Self => {
require('../methods/new')(Self);
//require('../methods/order/getTotalVolume')(Self);
require('../methods/order/getTotalVolume')(Self);
require('../methods/order/getVolumes')(Self);
require('../methods/order/getTotal')(Self);
require('../methods/order/itemFilter')(Self);
};