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

33 lines
849 B
JavaScript
Raw Normal View History

module.exports = Self => {
2020-09-09 13:49:59 +00:00
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: {
2021-08-12 09:21:59 +00:00
type: 'number',
root: true
},
http: {
2020-09-09 13:49:59 +00:00
path: `/:id/freightCost`,
verb: 'GET'
}
});
2021-08-12 09:21:59 +00:00
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;
};
};