salix/modules/agency/back/methods/agency/getShipped.js

29 lines
822 B
JavaScript

module.exports = Self => {
Self.remoteMethod('getShipped', {
description: 'Returns the first shipped possible for params',
accessType: 'READ',
accepts: [{
arg: 'params',
type: 'object',
required: true,
description: 'landed, addressFk, agencyModeFk'
}],
returns: {
type: 'object',
root: true
},
http: {
path: `/getShipped`,
verb: 'get'
}
});
Self.getShipped = async params => {
let query = `CALL vn.agencyHourGetShipped(?, ?, ?);
SELECT * FROM tmp.agencyHourGetShipped`;
let result = await Self.rawSql(query, [params.landed, params.addressFk, params.agencyModeFk]);
return result[1][0].shipped || null;
};
};