module.exports = Self => { Self.remoteMethod('getVAT', { description: 'Returns order total VAT', accessType: 'READ', accepts: [{ arg: 'id', type: 'number', required: true, description: 'order id', http: {source: 'path'} }], returns: { type: 'number', root: true }, http: { path: `/:id/getVAT`, verb: 'GET' } }); Self.getVAT = async orderId => { let totalTax = 0.00; let taxes = await Self.app.models.Order.getTaxes(orderId); taxes.forEach(tax => { totalTax += tax.tax; }); return Math.round(totalTax * 100) / 100; }; };