Created
February 24, 2015 11:22
-
-
Save lislon/a1507df5b789cf4d5c40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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