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

27 lines
708 B
JavaScript

module.exports = Self => {
Self.remoteMethod('freightCost', {
description: 'Returns the freight cost 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/freightCost`,
verb: 'GET'
}
});
Self.freightCost = async ticketFk => {
const [freightCost] = await Self.rawSql(`SELECT vn.ticket_getFreightCost(?) total`, [ticketFk]);
return freightCost.total;
};
};