@dhyasama/totem-models 11.14.0 → 11.15.0
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/Investment.js +23 -6
- package/package.json +1 -1
package/lib/Investment.js
CHANGED
|
@@ -93,24 +93,41 @@ module.exports = function(mongoose, config) {
|
|
|
93
93
|
|
|
94
94
|
if (err) return cb(err, null);
|
|
95
95
|
|
|
96
|
-
var
|
|
96
|
+
var investmentWithRoundDetails = _.map(investments, function(inv) {
|
|
97
|
+
|
|
98
|
+
var fund = null;
|
|
99
|
+
var organization = null;
|
|
100
|
+
var roundName = null;
|
|
97
101
|
|
|
98
102
|
var round = _.find(rounds, function(r) {
|
|
103
|
+
|
|
99
104
|
return _.some(r.vehicles, function(v) {
|
|
100
|
-
|
|
105
|
+
|
|
106
|
+
var investmentFound = _.some(v.investments, function(investmentId) {
|
|
101
107
|
return investmentId.toString() === inv._id.toString();
|
|
102
108
|
});
|
|
109
|
+
|
|
110
|
+
if (investmentFound) {
|
|
111
|
+
fund = v.fund;
|
|
112
|
+
organization = r.organization;
|
|
113
|
+
roundName = r.roundName;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return investmentFound;
|
|
117
|
+
|
|
103
118
|
});
|
|
119
|
+
|
|
104
120
|
});
|
|
105
121
|
|
|
106
122
|
return _.extend({}, inv.toObject(), {
|
|
107
|
-
organization:
|
|
108
|
-
round:
|
|
123
|
+
organization: organization,
|
|
124
|
+
round: roundName,
|
|
125
|
+
fund: fund
|
|
109
126
|
});
|
|
110
|
-
|
|
127
|
+
|
|
111
128
|
});
|
|
112
129
|
|
|
113
|
-
cb(null,
|
|
130
|
+
cb(null, investmentWithRoundDetails);
|
|
114
131
|
|
|
115
132
|
});
|
|
116
133
|
|