salix/modules/ticket/back/methods/ticket/getTotal.js

29 lines
727 B
JavaScript
Raw Normal View History

2018-04-17 12:49:55 +00:00
module.exports = Self => {
Self.remoteMethod('getTotal', {
description: 'Returns the total of a ticket',
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 ticketFk => {
let query = `SELECT vn.ticketGetTotal(?) AS amount`;
let [total] = await Self.rawSql(query, [ticketFk]);
return total.amount ? total.amount : 0.00;
};
2018-05-31 12:48:10 +00:00
};