salix/modules/route/back/models/route.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-03-22 10:10:23 +00:00
module.exports = Self => {
2019-04-25 06:28:08 +00:00
require('../methods/route/filter')(Self);
2019-03-22 10:10:23 +00:00
require('../methods/route/summary')(Self);
2019-03-25 12:16:34 +00:00
require('../methods/route/getTickets')(Self);
2019-04-04 11:06:41 +00:00
require('../methods/route/guessPriority')(Self);
require('../methods/route/updateVolume')(Self);
require('../methods/route/getDeliveryPoint')(Self);
require('../methods/route/insertTicket')(Self);
2020-12-24 10:31:20 +00:00
require('../methods/route/clone')(Self);
require('../methods/route/getSuggestedTickets')(Self);
require('../methods/route/unlink')(Self);
require('../methods/route/updateWorkCenter')(Self);
2022-09-26 06:07:45 +00:00
require('../methods/route/driverRoutePdf')(Self);
require('../methods/route/driverRouteEmail')(Self);
2020-02-18 11:51:29 +00:00
Self.validate('kmStart', validateDistance, {
message: 'Distance must be lesser than 1000'
});
Self.validate('kmEnd', validateDistance, {
message: 'Distance must be lesser than 1000'
});
function validateDistance(err) {
const routeTotalKm = this.kmEnd - this.kmStart;
const routeMaxKm = 1000;
2020-11-20 11:12:06 +00:00
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
2020-02-18 11:51:29 +00:00
err();
}
2019-03-22 10:10:23 +00:00
};