2018-07-09 11:54:43 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('landsThatDay', {
|
|
|
|
description: 'Returns a list of agencies that can land a shipment on a day for an address',
|
2019-11-11 15:32:03 +00:00
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'addressFk',
|
|
|
|
type: 'number',
|
|
|
|
required: true
|
|
|
|
}, {
|
|
|
|
arg: 'landed',
|
|
|
|
type: 'date',
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
],
|
2018-07-09 11:54:43 +00:00
|
|
|
returns: {
|
|
|
|
type: 'object',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/landsThatDay`,
|
|
|
|
verb: 'get'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-06-18 13:05:03 +00:00
|
|
|
Self.landsThatDay = async(addressFk, landed, options) => {
|
2021-11-18 10:17:30 +00:00
|
|
|
const myOptions = {};
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2019-11-10 13:13:55 +00:00
|
|
|
let query = `
|
2019-11-11 15:32:03 +00:00
|
|
|
CALL vn.zone_getAgency(?, ?);
|
2019-11-10 13:13:55 +00:00
|
|
|
SELECT * FROM tmp.zoneGetAgency;
|
|
|
|
DROP TEMPORARY TABLE tmp.zoneGetAgency;
|
|
|
|
`;
|
2021-06-18 13:05:03 +00:00
|
|
|
const result = await Self.rawSql(query, [addressFk, landed], myOptions);
|
2018-07-09 11:54:43 +00:00
|
|
|
|
2019-05-30 06:41:08 +00:00
|
|
|
return result[1];
|
2018-07-09 11:54:43 +00:00
|
|
|
};
|
|
|
|
};
|