diff --git a/client/order/src/card/index.js b/client/order/src/card/index.js index 648ca2bd6..02a494668 100644 --- a/client/order/src/card/index.js +++ b/client/order/src/card/index.js @@ -31,6 +31,13 @@ class Controller { if (res.data) this.order = res.data; }); + + query = `/order/api/Orders/${this.$state.params.id}/getTotal`; + this.$http.get(query).then(res => { + if (res.data) { + this.order.total = res.data.total; + } + }); } $onInit() { diff --git a/client/order/src/descriptor/index.html b/client/order/src/descriptor/index.html index f815f1774..706302d27 100644 --- a/client/order/src/descriptor/index.html +++ b/client/order/src/descriptor/index.html @@ -34,7 +34,7 @@ value="{{$ctrl.order.rows.length}}"> + value="{{$ctrl.order.total | currency: ' €': 2}}"> diff --git a/services/order/common/methods/order/getTotal.js b/services/order/common/methods/order/getTotal.js new file mode 100644 index 000000000..22d034d99 --- /dev/null +++ b/services/order/common/methods/order/getTotal.js @@ -0,0 +1,28 @@ +module.exports = Self => { + Self.remoteMethod('getTotal', { + description: 'Gets the total 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/getTotal`, + verb: 'GET' + } + }); + + Self.getTotal = async orderFk => { + let query = `SELECT hedera.orderGetTotal(?) total;`; + let [total] = await Self.rawSql(query, [orderFk]); + console.log(total); + return total; + }; +}; diff --git a/services/order/common/models/order.js b/services/order/common/models/order.js index 966d2750f..37d8d5298 100644 --- a/services/order/common/models/order.js +++ b/services/order/common/models/order.js @@ -1,3 +1,5 @@ module.exports = Self => { require('../methods/new')(Self); + //require('../methods/order/getTotalVolume')(Self); + require('../methods/order/getTotal')(Self); };