33 lines
849 B
JavaScript
33 lines
849 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, options) => {
|
|
const myOptions = {};
|
|
|
|
if (typeof options == 'object')
|
|
Object.assign(myOptions, options);
|
|
|
|
const [freightCost] = await Self.rawSql(`SELECT vn.ticket_getFreightCost(?) total`, [ticketFk], myOptions);
|
|
|
|
return freightCost.total;
|
|
};
|
|
};
|