Order.schema.pre('remove', function(next) {
if (this.orderstate == CONST_LOCKED) {
// record already locked - do not save - provide a message
debug ('Already Locked');
//req.flash('error', 'Already Locked Order!');
var delerr = new Error('Cannot Delete - Locked Order');
//return (delerr); // Do not delete
next (delerr);
}
else {
next ();
}
});