@dhyasama/totem-models 8.17.0 → 8.18.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/Financials.js +6 -26
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -211,39 +211,19 @@ module.exports = function(mongoose, config) {
|
|
|
211
211
|
|
|
212
212
|
Financials.statics.getByUUID = function getByUUID(uuid, cb) {
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
var self = this;
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
var query = self.findOne({
|
|
217
217
|
'snapshots.uuid': uuid
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
query.populate('organization', 'name logoUrl');
|
|
221
|
-
query.populate(
|
|
222
|
-
|
|
223
|
-
query.exec(function (err, result) {
|
|
224
|
-
|
|
225
|
-
if (err) {
|
|
226
|
-
return cb(err, null);
|
|
227
|
-
}
|
|
228
|
-
else if (!result) {
|
|
229
|
-
return cb(null, null);
|
|
230
|
-
}
|
|
231
|
-
else if (!result.customer) {
|
|
232
|
-
return cb(null, null);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
let customerId = result.customer._id;
|
|
236
|
-
|
|
237
|
-
_.each(result.snapshots, function (snapshot) {
|
|
238
|
-
|
|
239
|
-
snapshot.documents = _.filter(snapshot.documents, function (document) {
|
|
240
|
-
return document.customer = customerId;
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
|
|
221
|
+
query.populate({
|
|
222
|
+
path: 'snapshots.documents',
|
|
245
223
|
});
|
|
246
224
|
|
|
225
|
+
query.exec(cb);
|
|
226
|
+
|
|
247
227
|
};
|
|
248
228
|
|
|
249
229
|
Financials.statics.getByPostmarkMessageId = function getByPostmarkMessageId(postmarkMessageId, cb) {
|