salix/modules/zone/back/models/zone.js

32 lines
1015 B
JavaScript

module.exports = Self => {
require('../methods/zone/clone')(Self);
require('../methods/zone/getLeaves')(Self);
require('../methods/zone/getEvents')(Self);
require('../methods/zone/getEventsFiltered')(Self);
require('../methods/zone/toggleIsIncluded')(Self);
require('../methods/zone/getUpcomingDeliveries')(Self);
require('../methods/zone/deleteZone')(Self);
require('../methods/zone/includingExpired')(Self);
require('../methods/zone/getZoneClosing')(Self);
require('../methods/zone/exclusionGeo')(Self);
require('../methods/zone/updateExclusionGeo')(Self);
Self.validatesPresenceOf('agencyModeFk', {
message: `Agency cannot be blank`
});
Self.validatesPresenceOf('price', {
message: 'Price cannot be blank'
});
Self.validateAsync('price', priceIsValid, {
message: 'Price must be greater than 0'
});
async function priceIsValid(err, done) {
if (this.price <= 0)
err();
done();
}
};