@dhyasama/totem-models 6.11.6 → 6.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Organization.js +8 -8
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -450,12 +450,12 @@ module.exports = function(mongoose, config) {
|
|
|
450
450
|
// Deals aren't on for customer
|
|
451
451
|
else if (!self.customer.deals.active) return [];
|
|
452
452
|
|
|
453
|
-
// Get active
|
|
454
|
-
var
|
|
455
|
-
|
|
456
|
-
|
|
453
|
+
// Get active stage names and sort them
|
|
454
|
+
var stages = _.filter(self.customer.deals.stages, function(s) { return s.active; });
|
|
455
|
+
stages = _.sortBy(stages, 'order');
|
|
456
|
+
stages = _.pluck(stages, 'name');
|
|
457
457
|
|
|
458
|
-
return
|
|
458
|
+
return stages;
|
|
459
459
|
|
|
460
460
|
});
|
|
461
461
|
|
|
@@ -755,10 +755,10 @@ module.exports = function(mongoose, config) {
|
|
|
755
755
|
if (err) return callback(err, null);
|
|
756
756
|
else if (!org) return callback(new Error('Customer not found'), null);
|
|
757
757
|
|
|
758
|
-
var
|
|
758
|
+
var stages = org.customer.deals.activeStatuses;
|
|
759
759
|
|
|
760
|
-
var match = _.find(
|
|
761
|
-
return
|
|
760
|
+
var match = _.find(stages, function(stage) {
|
|
761
|
+
return stage == previous.deal.stage;
|
|
762
762
|
});
|
|
763
763
|
|
|
764
764
|
if (!match) return callback(new Error('This stage is not valid for this customer'), null);
|