@dhyasama/totem-models 11.18.0 → 11.19.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/Organization.js +45 -0
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -1703,6 +1703,51 @@ module.exports = function(mongoose, config) {
|
|
|
1703
1703
|
|
|
1704
1704
|
};
|
|
1705
1705
|
|
|
1706
|
+
Organization.statics.getValuationsForOrgs = function getValuationForOrgs(orgIds, customerId, startDate, endDate, options, cb) {
|
|
1707
|
+
|
|
1708
|
+
const self = this;
|
|
1709
|
+
|
|
1710
|
+
if (!cb) {
|
|
1711
|
+
throw new Error('cb is required');
|
|
1712
|
+
}
|
|
1713
|
+
if (!orgIds) {
|
|
1714
|
+
return cb(new Error('orgIds is required'), null);
|
|
1715
|
+
}
|
|
1716
|
+
if (!options) {
|
|
1717
|
+
return cb(new Error('options is required'), null);
|
|
1718
|
+
}
|
|
1719
|
+
if (!customerId) {
|
|
1720
|
+
return cb(new Error('customerId is required'), null);
|
|
1721
|
+
}
|
|
1722
|
+
if (!startDate) {
|
|
1723
|
+
return cb(new Error('startDate is required'), null);
|
|
1724
|
+
}
|
|
1725
|
+
if (!endDate) {
|
|
1726
|
+
return cb(new Error('endDate is required'), null);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
let query = self
|
|
1730
|
+
.find({
|
|
1731
|
+
'_id': { $in: orgIds },
|
|
1732
|
+
'valuations': {
|
|
1733
|
+
$elemMatch: {
|
|
1734
|
+
'date': { $gte: startDate, $lte: endDate },
|
|
1735
|
+
'customer': customerId
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
})
|
|
1739
|
+
.select('_id valuations');
|
|
1740
|
+
|
|
1741
|
+
query.exec(function(err, orgs) {
|
|
1742
|
+
|
|
1743
|
+
if (err) { return cb(err, null); }
|
|
1744
|
+
|
|
1745
|
+
return cb(null, orgs);
|
|
1746
|
+
|
|
1747
|
+
});
|
|
1748
|
+
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1706
1751
|
Organization.statics.getFlags = function getFlags(orgid, options, cb) {
|
|
1707
1752
|
|
|
1708
1753
|
const self = this;
|