Skip to content

Instantly share code, notes, and snippets.

@lislon
Created February 24, 2015 11:22
Show Gist options
  • Select an option

  • Save lislon/a1507df5b789cf4d5c40 to your computer and use it in GitHub Desktop.

Select an option

Save lislon/a1507df5b789cf4d5c40 to your computer and use it in GitHub Desktop.
service.updateJob = function (orderId, attributes, done) {
service.jobFieldsValidation.check(attributes).then(function (attributes){
var Order = derp.db.model('Order');
service.getById(orderId, {
where: {
stage: {
$gte: Order.STAGE.PASSPORT,
$lt: Order.STAGE.MISC_AND_CONFIRM
}
}
}, function (err, loanOrder) {
if (err) { return done(err); }
attributes.orgExtra = {};
data.cleanAddresses([attributes.orgAddress], function (err, result) {
if (err) { return done(err); }
attributes.orgAddressExtra = result[0];
attributes.orgAddress = attributes.orgAddressExtra.source
loanOrder.set({ job: _.pick(attributes, Order.FIELDS.JOB.concat(['orgExtra', 'orgAddressExtra'])) });
if (loanOrder.stage < Order.STAGE.JOB) {
loanOrder.set({stage: Order.STAGE.JOB});
}
loanOrder.save(done);
});
});
}, function (err) { done(new errors.Validation(err)); })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment